简体   繁体   English

C ++ Boost Link错误

[英]C++ Boost Link error

I am working on Windows 10 and I downloaded Boost 1.60 for Visual Studio 2015. 我正在Windows 10上工作,我为Visual Studio 2015下载了Boost 1.60。

My first code snippet looks as: 我的第一个代码段如下所示:

#include <boost/thread.hpp>
#include <vector>
#include <iostream>
#include <sstream>
#include <cmath>
#include <iostream>

using namespace std;
void main()
{
    std::cout << "Hello World";

}

I get the error: 我收到错误:

>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc140-mt-gd-1_60.lib'

I have provided path for boost and also libraries as shown in pics: 我提供了boost的路径,还提供了如图所示的库:

在此处输入图片说明

在此处输入图片说明

You need to compile the library before using it. 您需要先编译库,然后再使用它。 Here's how to compile it: 编译方法如下:

In your Windows Start menu open the "Developer Command Prompt for VS2015". 在Windows的“开始”菜单中,打开“ VS2015的开发人员命令提示符”。 Then inside the opened command prompt, execute those commands: 然后在打开的命令提示符下,执行以下命令:

cd C:\\boost_1_60_0

bootstrap.bat

.\\b2 runtime-link=shared toolset=msvc-14.0

Wait for a couple of minutes, since compilation takes a while. 等待几分钟,因为编译需要一段时间。

Specify in your project in Linker -> General , the Additional Library Directories path as C:\\boost_1_60_0\\stage\\lib , and in C++ -> General the Additional Include Directories path as C:\\boost_1_60_0 在项目的C:\\boost_1_60_0\\stage\\lib > General中 ,将Additional Library Directories路径指定为C:\\boost_1_60_0\\stage\\lib ,在C ++-> General中,Additional Include Directories路径指定为C:\\boost_1_60_0

You should now be able to compile your code without problem. 现在,您应该可以毫无问题地编译代码了。

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

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