如何将外部静态库添加到 Visual C++ 2010年快递项目

发布于 2024-09-17 22:48:00 字数 240 浏览 2 评论 0原文

我不敢相信我很难弄清楚如何做这么简单的事情。我有一个外部库(包括 .lib 和 .h 文件),我想将其添加到我的项目中。根据我所读到的内容,我需要转到“项目”>“属性”>“框架和引用”>“添加新引用”并将其添加到此处。

然而,这个窗口是空白的。有一个项目名称和项目目录列,但那里没有任何内容,也没有“浏览”按钮来查找我的库。我尝试进入 VC++ 目录并将 .lib 文件的路径添加到库路径,但没有帮助。

我缺少什么?

I can't believe I'm having such a hard time figuring out how to do something so simple. I have an external library (including a .lib and .h file) that I want to add to my project. From what I've read I need to go Project>Properties>Framework and references>Add new References and add it there.

However, this window is blank. There is a Project name and Project Directory column but there is nothing there and no 'browse' button to find my library. I tried going to VC++ directory and adding the path to the .lib file to the libraries path but it didn't help.

What am I missing?

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

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

发布评论

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

评论(2

(り薆情海 2024-09-24 22:48:00

如果您有外部文件,则无法使用引用选项卡,因为它仅引用当前解决方案中的项目,因此您必须手动操作。

要实现您的目标,您只需按照以下步骤操作:

  1. 左键单击您的项目,然后选择属性
  2. 属性对话框中转到配置属性(在下一步中,我们将始终假设位于配置属性下)
  3. C/C++ -> 中常规编辑其他包含目录属性,添加头文件(.h文件)的路径
  4. 链接器中 - >常规编辑其他库目录属性,添加静态库(.lib文件)的路径
  5. 链接器中 - >输入编辑附加依赖项属性,添加库的名称(.lib文件的名称

现在您可以轻松地使用静态库中的函数,只需在代码文件中包含 .h 标头 ( #include "myLib.h" )

If you have external files you cannot use the reference tab because it just references project in the current solution, so you have to to it manually.

To reach your goal you just need to follow the following step

  1. Left clik on your Project and select Properties
  2. In the Properties Dialog go to Configuration Properties (in the next step we will always assumet to be under Configuration Properties)
  3. In C/C++ -> General edit the Additional Include Directories property adding the path to your header file (.h file)
  4. In Linker -> General edit the Additional Library Directories property adding the path to your static library (.lib file)
  5. In Linker -> Input edit the Additional Dependencies property adding the name of your Library (name of your .lib file)

Now you can easily use the function in your static library just including the .h header in your code file ( #include "myLib.h" )

冧九 2024-09-24 22:48:00

项目->属性->配置属性->链接器->命令行。在那里拼写 your_lib_name.lib 以与其链接。或者 - 使用“链接器”->“输入”->“附加依赖项”选项(其作用与在命令行中直接指定库相同)。
至于.h - 只需#include即可。不过,您可能想为其添加包含路径。

Project->Properties->Configuration Properties->Linker->Command Line. Spell your_lib_name.lib there to link with it. Alternatively - use Linker->Input->Additional dependencies option (it does the same as directly specifying libs in command line).
As for .h - just #include it. You might want to add include path for it, though.

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