如何将静态库添加到Visual Studio项目 [英] How to add static libraries to a Visual studio project

查看:493
本文介绍了如何将静态库添加到Visual Studio项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将静态库添加到我的项目中。要添加静态库,我正在按照Microsoft的说明进行操作: http://msdn.microsoft。 com / en-us / library / ms235627.aspx
我的问题是我在向我的项目添加引用时看不到依赖库。



在上述教程中,他们提到应将依赖项(即静态库)添加到解决方案中。



解决方案

您提供的教程是指您创建自己的静态库的情况-在这种情况下,您可能希望将其添加到解决方案中,从而使其成为解决方案的组成部分;但是我认为您正在尝试添加外部库(不是您自己创建的,例如从网上下载的),这就是您被卡住的原因。



属性页面,请转到 C / C ++->常规->其他包含目录并提供路径,您要使用的库的头文件位于该路径。



然后转到 Linker-> General-> Additional Library Directories 并指定.lib文件所在的路径。



最后,转到 Linker-> Input-> Additional Dependencies ,然后添加包含库的文件名及其扩展名(例如example_library.lib)。 p>

仅此而已。现在您应该可以使用该库了。请记住将其包含在文件中,并为您的平台使用正确的模式(发行/调试)和正确的版本(x64 / win32)。对于您的应用的发行版和调试版,您可能必须重复上面给出的步骤。


I am trying to add static libraries to my project. To add the static library I am following Microsoft's instructions: http://msdn.microsoft.com/en-us/library/ms235627.aspx. My problem is I that am not able to see the dependent library while adding the reference to my project.

In the tutorial mentioned above, they have mentioned that the dependency (ie. static library), should be added to the solution.

解决方案

The tutorial you have provided refers to a case in which you create your own static library - in this case you may want to add it to your solution and thus make it an integral part of the solution; but I assume you are trying to add external libraries (not created by you, e.g. downloaded from the net) - that is why you got stuck.

On Property Pages, go to C/C++->General->Additional Include Directories and provide the path, where the header file of the library that you want to use is located.

Then go to Linker->General->Additional Library Directories and specify the path, where your .lib file is located.

Finally, go to Linker->Input->Additional Dependencies and add the name of the file containing your library together with its extension (e.g. example_library.lib).

That is all. Now you should be able to use the library. Remember to #include it in your files and use the right mode (release/debug) and the right version for your platform (x64/win32). You may have to repeat the steps given above both for release and debug versions of your app.

这篇关于如何将静态库添加到Visual Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆