简体   繁体   English

在Microsoft Visual Studio 2010中添加.lib文件

[英]Adding .lib files in Microsoft Visual Studio 2010

I just downloaded Visual Studio 2010, and they changed a lot since Visual Studio 2008. These options were changed: the header includes, the lib directory to add, and all changed. 我刚刚下载了Visual Studio 2010,自Visual Studio 2008以来,它们进行了很多更改。这些选项已更改:标头包括,要添加的lib目录,并且所有更改。

I followed a series of tutorials to do that, but in the other version I just had to add the mylib.lib string in the textfield, but now I look over and over, and I can't find a place to paste that mylib.lib to link with my project. 我遵循了一系列教程来做到这一点,但是在其他版本中,我只需要在文本字段中添加mylib.lib字符串,但是现在我一遍又一遍,找不到一个粘贴该mylib的地方。 lib链接到我的项目。

Where can I find it? 在哪里可以找到它?

If you're looking for how to get a lib file imported in to your project, you can do this either by editing the project settings, under Linker>Input: 如果要查找如何将lib文件导入到项目中,可以通过在Linker> Input下编辑项目设置来执行此操作:

在此处输入图片说明

...or you can use a #pragma ... ...或者您可以使用#pragma ...

#pragma comment( lib, "MyLib.lib" )

I typically add this right in to the header file for the library I want to import. 我通常将此权限添加到要导入的库的头文件中。 Alternatively, you can add it to any header or CPP file in your project. 或者,您可以将其添加到项目中的任何头文件或CPP文件中。

I personally prefer to do it this way, right in code: 我个人更喜欢以这种方式在代码中这样做:

#pragma comment(lib, "mylib.lib")

This way you don't need to look for the field you need under project settings. 这样,您无需在项目设置下查找所需的字段。

See also: What does "#pragma comment" mean? 另请参阅: “ #pragma注释”是什么意思?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM