Error LNK2019
  • Hi all,

    I'm trying to develop an app in C++ using the Basecam Libraries in Visual Studio 2015. I have followed all the instructions but i can't understand what its the problem. Visual Studio throws this error:



    Error LNK2019 external symbol "void __cdecl SBGC_cmd_control_pack(struct SBGC_cmd_control_t &,class SerialCommand &)" (?SBGC_cmd_control_pack@@YAXAAUSBGC_cmd_control_t@@AAVSerialCommand@@@Z) not resolved, reference function "unsigned char __cdecl SBGC_cmd_control_send(struct SBGC_cmd_control_t &,class SBGC_Parser &)" (?SBGC_cmd_control_send@@YAEAAUSBGC_cmd_control_t@@AAVSBGC_Parser@@@Z) gimbalCommunication C:\Users\Rex\Documents\Visual Studio 2015\Projects\gimbalCommunication\gimbalCommunication\gimbalCommunication.obj 1




    The code is:

    #include "stdafx.h"
    #include
    #include
    #include "SBGC_lib\SBGC.h"

    class PCComObj : public SBGC_ComObj
    {
    HANDLE hSerial;
    DCB dcb;
    DWORD dwBytesRead = 0;
    DWORD byteswritten = 0;

    public:
    void init(CString puerto) {

    hSerial = CreateFile(puerto,
    GENERIC_READ | GENERIC_WRITE,
    0,
    0,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    0);
    dcb.BaudRate = 115200;
    dcb.ByteSize = 8;
    dcb.Parity = NOPARITY;
    dcb.StopBits = ONESTOPBIT;
    if (!SetCommState(hSerial, &dcb))
    printf("Error con el puerto");

    }
    // Return the number of bytes received in input buffer
    uint16_t getBytesAvailable()
    {
    return GetFileSize(hSerial, NULL);
    }
    // Read byte from the input stream
    uint8_t readByte()
    {
    BYTE Byte;
    ReadFile(hSerial, &Byte, 1, &dwBytesRead, 0);
    return Byte;
    }
    // Write byte to the output stream
    void writeByte(uint8_t b)
    {
    WriteFile(hSerial, &b, 1, &byteswritten, NULL);
    }
    // Return the space available in the output buffer. Return 0xFFFF if unknown.
    uint16_t getOutEmptySpace()
    {
    return 0xFFFF;
    }
    };

    PCComObj com_obj;
    SBGC_Parser sbgc_parser;
    SerialCommand a;

    int main()
    {
    com_obj.init("COM4");
    sbgc_parser.init(&com_obj);

    SBGC_cmd_control_t c;

    /////////////////// Demo 1. PITCH and YAW gimbal by 40 and 30 degrees both sides and return back.
    // Actual speed depends on PID setting.
    // Whait 5 sec to finish
    c.mode = SBGC_CONTROL_MODE_ANGLE;
    c.anglePITCH = SBGC_DEGREE_TO_ANGLE(40);
    c.angleYAW = SBGC_DEGREE_TO_ANGLE(30);

    SBGC_cmd_control_send(c, sbgc_parser);

    c.anglePITCH = SBGC_DEGREE_TO_ANGLE(-40);
    c.angleYAW = SBGC_DEGREE_TO_ANGLE(-30);
    SBGC_cmd_control_send(c, sbgc_parser);

    getchar();
    return 0;
    }


    The program crashes when SBGC_cmd_control_send(c, sbgc_parser); appears. Any suggestions?

    Thanks in advance.

  • Solved ;).