Can not open the file "libboost_thread-vc141-mt-gd-1_69.lib" solution

Visual Studio 2017 configures the Boost library, how to compile and select, and encounter the solution that the file "libboost_thread-vc141-mt-gd-1_69.lib" cannot be opened...

 

1. Go to the official website to download boost, www.boost.org here I downloaded version 1-69.

2. Install and run the bootstrap.bat file after decompression. Wait a while and it will be OK.

3. Compile the boost library . Note that you must use the x86 native tool command prompt of VS2017, which can be found in the installation menu of VS2017. Enter the command line prompt and enter the following:

bjam -j4 --debug-symbols=on --build-type=complete toolset=msvc-14.1 threading=multi runtime-link=shared address-model=32

Note that the runtime library type specified here is a dynamic link library:
runtime-link=shared

Of course, you can also choose a static library, just specify it like this:
runtime-link=static 

Depending on the computer configuration, it may take 30 minutes to an hour if it is too low. Then wait for the compilation to complete.

After compiling, the screen will have the following prompt:

...updated 2376 targets...


The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    E:\boost_1_69_0\boost_1_69_0

The following directory should be added to linker library paths:

    E:\boost_1_69_0\boost_1_69_0\stage\lib

4. Configure the boost environment in VS2017

Project Properties> Configuration Properties, and then see the following options:
    General> Platform Tools, select Visual Studio 2017 (v141).
The two operations below require you to replace the directory that you told you when the boost was compiled above to the following Go inside the relevant catalog information.
    See "C\C++" General>Additional include directory, add "E:\boost_1_69_0\boost_1_69_0" and
    finally, see "Linker" General>Additional library directory, add "E:\boost_1_69_0\boost_1_69_0\stage\lib"

Note: Be sure to make this correct setting, otherwise there will always be problems when compiling programs that use boost.


5. Use boost :

#include "stdafx.h"
#include <iostream>  
#include <boost/thread/thread.hpp>  
void hello()
{
std::cout << "Hello world, I'm a thread!" << std::endl;
}
int main()
{
boost::thread thrd(&hello);
thrd.join();
}

Error:

Error LNK1104 Cannot open the file "libboost_thread-vc140-mt-gd-1_63.lib"


Solution:

Because the above selection is the boost library compiled in the form of a dynamic link library, here we have to choose a multi-threaded debugging DLL (/MDd).

Go and run it again. It's OK.

6. Reference materials

Newcomer, it’s the first time to use C++, and now there are very few people using C++. After asking a circle, no one will answer this question. I have searched a lot of information. Here are some useful reference materials:
http://blog.csdn.net The
title of /zhaoya_huangqing/article/details/47318479 is similar to me, thank you for this blogger.

http://www.cnblogs.com/rok-aya/p/4986261.html
reposted the foreigner's article, very enlightening, and the problem of this article is right.

https://msdn.microsoft.com/zh-cn/vstudio/669zx6zc.aspx
MSDN's official guidance how to implement project properties, advanced

http://www.cnblogs.com/mr-wid/archive/2013/01/22/2871105.html
http://www.cnblogs.com/wendao/archive/2011/11/28/article2_boost_bind.html
boost learning Some of the articles are worthy of reference.

 

From: https://blog.csdn.net/weixin_33801856/article/details/85844981?utm_medium=distribute.pc_relevant.none-task-blog-title-6&spm=1001.2101.3001.4242

Guess you like

Origin blog.csdn.net/hyl999/article/details/108959988