我从供应商那里获得了一个 dll,我想在 C++ Visual Studio 2012 项目中使用它。它带有一个.lib文件。
链接时我得到:
Error 1 error LNK2019: unresolved external symbol __imp__FT_CreateDeviceInfoList referenced in function "int __cdecl Ftexam(void)" (?Ftexam@@YAHXZ) C:\Users\Terry\Documents\Visual Studio 2012\Projects\Win32Project1\Win32Project1\ftexam.obj ftexample
Run Code Online (Sandbox Code Playgroud)
我读过类似的帖子,但我一无所获。我认为我正在根据这些答案做所有事情,但在链接时我仍然收到未定义的参考错误。
dll.lib文件放入我的项目目录中,并确保如果我从那里删除它,我会cannot find dll.lib在链接时得到(即,它是“在构建中”)在我提供的dll.h头文件中,我有这个:
#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
.
.
#ifdef __cplusplus
extern "C" {
#endif
typedef ULONG FT_STATUS;
.
.
DLL_API FT_STATUS FT_CreateDeviceInfoList(
LPDWORD lpdwNumDevs
);
Run Code Online (Sandbox Code Playgroud)
我的调用代码是:
#include …Run Code Online (Sandbox Code Playgroud)