我有一个第三方库(比如 tp.lib)和第三方 dll(比如 tp.dll),我需要在我的 C++ 项目中使用它们(我的项目制作了一个 dll,我们称它为 my.dll ).
我在头文件中包含了带有#pragma comment(lib, "libraryname") 的库 并且还在我的 C++ Visual Studio 项目中的 configurationproperties->linker->additional library directories 中包含库文件的路径。
代码编译和链接正常。但无法执行。当我使用 depends 来检查我是否遗漏了什么时,我观察到没有找到 tp.dll。 tp.dll 与 tp.lib 位于同一个库文件夹中。
我应该怎么做才能将 tp.dll 包含到 my.dll 中?
最佳答案
DLL 有不同的搜索路径。以下引自 docs :
With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence:
The directory where the executable module for the current process is located.
The current directory.
The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
The directories listed in the PATH environment variable.
Note The LIBPATH environment variable is not used.
关于c++ - 将库和 dll 包含到 C++ 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12823105/