C++ 将 .lib 文件添加到 Visual Studio 2015 中的项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36785220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 14:38:24  来源:igfitidea点击:

Adding a .lib file to a project in Visual Studio 2015

c++windowsvisual-studiovisual-c++static-libraries

提问by john g

I have generated a .libfile from another project that I would like to use in my project. I have added the file to LinkerInputAdditional dependenciesas bluetoothserialport.lib.

.lib从另一个项目生成了一个文件,我想在我的项目中使用它。我已将该文件添加到LinkerInputAdditional dependenciesas bluetoothserialport.lib.

I've added the lib file inside my project at this level: http://i65.tinypic.com/1t9fki.jpg

我在这个级别的项目中添加了 lib 文件:http: //i65.tinypic.com/1t9fki.jpg

However I get the following error:

但是我收到以下错误:

1>LINK : fatal error LNK1104: cannot open file 'bluetoothserialport.lib'

1>LINK:致命错误 LNK1104:无法打开文件“bluetoothserialport.lib”

I am using Windows 10 and C++.

我正在使用 Windows 10 和 C++。

回答by Chris Becke

If you come from an Xcode background you might expect a reasonable IDE to know what all the things in a project are. Visual Studio is not such an IDE.

如果您有 Xcode 背景,您可能会期望一个合理的 IDE 知道项目中的所有内容。Visual Studio 不是这样的 IDE。

You need to, explicitly, go to the LinkerGeneralAdditional Library Directories, and add a path to your .lib there.

您需要明确地转到LinkerGeneralAdditional Library Directories,并在那里添加到您的 .lib 的路径。