Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设 A 类仅在 dll 库的头文件中定义(在 cpp 中没有实现),如下所示,有两种方式:
class __declspec(dllimport) A {...}; class A {...};
我尝试在我的应用程序中使用该库,我发现第一个不起作用。为什么?有什么方法可以使它与 dllimport 一起使用?谢谢。
它__declspec(import)有两个下划线,而不是一个。
__declspec(import)
除此之外,如果您使用的库是使用不同版本的 Visual Studio 编译的,它很可能找不到它尝试导入的符号。
应该假设由于潜在的 ABI 更改,使用一个版本的 Visual Studio 编译的库将无法链接到使用另一个版本的 Visual Studio 编译的库。
您需要使用与尝试链接它的应用程序相同的 Visual Studio 版本来编译 DLL。