在C ++中从头文件调用函数时发生LNK2019错误

问题描述 投票:0回答:1

我正在尝试从头文件LG101API.h调用API。我在Leds.cpp中将其链接为#include“ LG101API.h”。该项目具有dll和libLG101API.dllLG101API.lib。我在链接器>输入中链接库,并将路径添加到链接器>通用>其他库目录。现在我继续得到

LNK2019 unresolved external symbol "__declspec(dllimport) int __stdcall KC_LG101_OPENPORT(int,int)" (__imp_?KC_LG101_OPENPORT@@YGHHH@Z) referenced in function _main

这里是标题代码

#ifdef LG101API_EXPORTS
#define LG101API_API __declspec(dllexport)
#else
#define LG101API_API __declspec(dllimport)
#endif


// This class is exported from the LG101API.dll
class LG101API_API CLG101API {
public:
    CLG101API(void);
    // TODO: add your methods here.
};

extern LG101API_API int nLG101API;

//////////////////////////////////////////////////////////////////////////
LG101API_API int _stdcall KC_LG101_OPENPORT(int iCom, int iPort);
LG101API_API int _stdcall KC_LG101_CLOSEPORT(void);
LG101API_API int _stdcall KC_LG101_SETLED(int iLed, int iTurnOn);
LG101API_API int _stdcall KC_LG101_READLED(int* iLEDst);
LG101API_API int _stdcall KC_LG101_READGUARD(int* iGUARDst);
LG101API_API int _stdcall KC_LG101_SETLEDMODE(int iGroup, int iOnTm, int iOffTm);

//////////////////////////////////////////////////////////////////////////
LG101API_API int _stdcall KC_LG101_RESET();
LG101API_API int _stdcall KC_LG101_CONTROLLED(int iLed, int iOnOff, int iOnTm, int iOffTm);
LG101API_API int _stdcall KC_LG101_SETTWINKLE(int* iLedArray, int iOnTm, int iOffTm);
LG101API_API int _stdcall KC_LG101_SETBOOT(int* iLedArray, int* iTwinkleLedArray, int iOnTm, int iOffTm);
LG101API_API int _stdcall KC_LG101_READLEDST(int* iLedArray, int* iTwinkleLedArray);
LG101API_API int _stdcall KC_LG101_GETVERSION(int* iVer);

这是我在main中如何调用它的方法>>

KC_LG101_OPENPORT(1, 9600);
    KC_LG101_SETLED(1, 1);

我正在尝试从头文件LG101API.h调用API。我在Leds.cpp中将其链接为#include“ LG101API.h”。该项目具有一个dll和libLG101API.dll LG101API.lib。我在链接器> ...

c++
1个回答
0
投票
  1. 任何查看者查看.lib文件并找到字符串(如果不能-库中有麻烦):
© www.soinside.com 2019 - 2024. All rights reserved.