c++ - 将库和 dll 包含到 C++ 项目中

标签 c++ visual-studio-2010 dll dynamic-linking

我有一个第三方库(比如 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:

  1. The directory where the executable module for the current process is located.

  2. The current directory.

  3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

  4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

  5. 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/

相关文章:

c++ - 这是符合标准的有效 C++ 代码吗?

c++ - D3D11 : How to draw GDI Text to a GXDI Surface?(无 D2D)

c# - 使项目在多个 .NET 版本之间保持同步

visual-studio-2008 - Windows 上的 SQL Server CE 安装 - 只需引用 DLL 就完成了?

gcc - 关于 .so 和 .dll 文件的一般问题

c# - 在 C# 和 F# 之间交换大列表

c++ - VS2012 如何通过 IntelliSense 显示标准 C++ 库的文档?

c++ - 打印的二叉树问题。用户输入不打印任何内容

c++ - Visual C++ 异或加密错误

c++ - 编译 Zeus 时出现“具有 block 作用域的静态函数是非法的”错误