I have created a simple static library project and a Win32 console project to call a function.
// static lib code
// Test.h
void abf();
// Test.cpp
void abf()
{
}
// Caller Project code
// MyTest.cpp
#include "Test.h
int main()
{
abf();
return 0;
}
Static library compiles without an error. But caller project gives following error.
error LNK2019: unresolved external symbol "void __cdecl abf(void)" (?abf@@YAXXZ) referenced in function _main
I tried a few things such as putting the function in extern "C" block, exporting using __declspec(dllexport) but nothing seems to work.
Any ideas?
在 test.h 中使用 __declspec(dllexport) 导出您的符号
extern "C" __declspec(dllexport) void abf(void);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.