Visual C++表达我到底如何链接第三方库 DLL

发布于 2024-12-12 10:37:30 字数 223 浏览 3 评论 0原文

是的,我已经看到了您所需要做的就是链接它的帖子。找到你的.lib 和链接。我有 10 年的 IT 经验,我根本不清楚链接设置在哪里/如何进行。这是一个不在其他项目中的 DLL。我有这个库,我花了几个小时试图找出如何将其引入。只是好奇,为什么没有一些选项卡显示外部库,以及一个浏览按钮来转到您将其存储在文件系统上的任何位置?我只是没有得到链接该文件的多个步骤。请有人拼出来。我使用的是 Visual C++ Express 2010。

YES, I have seen the posts that all you need to do is link it. Find you .lib and link. I have 10 years IT experience and its not at all clear to me where/how the link settings are made. This is a DLL that is not in another project. I have the lib and I have spent hours just trying to find out how to pull this in. Just curious, why there is not some tab saying external libraries, and a browse button to goto whereever you stored this on your file system? I just don't get the multiple steps to get this file linked up. Someone please spell it out. I'm on Visual C++ Express 2010.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你在我安 2024-12-19 10:37:30

您是否尝试过仅使用“将现有文件添加到项目”,浏览到 .lib 并添加它? Visual Studio 可识别文件类型并将 .lib 文件传递​​给链接器。

还有另一种方法更复杂,也更强大。您可以通过右键单击“解决方案资源管理器”中的项目来打开项目属性。然后转到“项目目录”并将路径添加到 LIB 路径,然后转到“链接器输入”并在其他输入下添加库名称(不带路径)。第二种方法的优点是,您可以使用不同版本的 .lib 和 .dll 用于发布与调试,或 32 位与 64 位构建。

Did you try just using "Add Existing File to Project", browsing to the .lib and adding it? Visual Studio recognizes the file type and passes .lib files to the linker.

There's another way which is more complicated and also more powerful. You can open the project properties by right-clicking the project in Solution Explorer. Then go to the Project Directories and add the path to the LIB paths, then go to Linker Input and add the library name (without path) under additional inputs. The advantage of this second method is that you can have different versions of the .lib and .dll for release vs debug, or 32-bit vs 64-bit builds.

深白境迁sunset 2024-12-19 10:37:30

除了 Bens 答案之外,您还可以使用 pragma 指令:

#pragma comment ( lib, "path-to-library-file.lib" )

有些人喜欢在项目中链接库,其他人则喜欢在源文件中。无论哪种方式都没有太大区别。

In addition to Bens answer, you can also use pragma directives:

#pragma comment ( lib, "path-to-library-file.lib" )

Some prefer linking libraries in the project, others prefer it in the source file. It doesn't make much of a difference either way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文