Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

c++ - How to build boost Version 1.58.0 using Visual Studio 2015 (Enterprise)

I like to build boost 1.58.0 using the (new) Visual Studio 2015 (Enterprise). In the past I proceeded in the following way:

  1. Download boost 1.58.0 from www.boost.org
  2. Extract files (e.g. C:hirdpartyvs2013x64oost_1_58_0)
  3. Start Visual Studio 2013 x64 command prompt (VS2013 x64 Native Tools Command Prompt)
  4. Change to boost directory (e.g. cd C:hirdpartyvs2013x64oost_1_58_0)
  5. Execute .ootstrap.bat
  6. Execute .2 -j8 --toolset=msvc-14.0 address-model=64 --build-type=complete stage
  7. b2 -j8 --toolset=msvc-12.0 address-model=64 --build-type=complete stage --with-python

But in VS2015 there is not VS2015 command prompt.

Also the vcvarsall.bat is missing that I used sometimes to setup a VS2013 command prompt.

How can I compile the source code of boost using VS2015?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Unfortunately Boost documentation is quite verbose because it tries to take care of all OS and environments. Also, it skips over some time saving details. Here's quick steps specifically for VS2015 with Boost 1.61.

First, let's understand that Boost is huge library with lots of contributors. Consequently, all of the Boost code is divided in to two parts: headers only libraries and header+cpp libraries. The former doesn't require compilation. You just include them and you are done. Later does require building. You typically don't need to worry about extra steps of building, although its good idea to just set everything up once.

Using Boost Header Only Libraries

  1. Download the Boost archive in 7z format and extract using 7Zip. The zip file is much bigger than 7z file and can take over 20 minutes to extract by Windows Explorer vs 5 minutes by 7Zip.
  2. Create folder c:Program Filesoost. Copy extracted boost_1_61_0 folder in this folder. This exact path is not a requirement but we will use that here.
  3. In whatever VC++ project you want to use Boost, go to that project's right click Properties > C/C++ > General > Additional Include Directories and add path C:Program Filesoostoost_1_61_0 without quotes.

Now you should be able to use most of the Boost libraries by using statement like #include <boost/thread/mutex.hpp>.

Using Boost Header+CPP Libraries

Examples of these are Boost.Chrono, Boost.Filesystem, Boost.GraphParallel, Boost.IOStreams, Boost.Locale, Boost.Regex, Boost.Thread, Boost.System etc. Unless you are using these libraries, following steps are not needed.

  1. First make sure you don't have Windows Driver Kit installed. If you have, uninstall it for now because most likely it has messed up include paths that will cause Boost's build script to fail.
  2. Invoke VS2015 x64 Native Tools Command Prompt as Administrator.
  3. CD to C:Program Filesoostoost_1_61_0 and then run bootstrap.bat.
  4. Run .2
  5. Run .2 variant=debug,release link=static runtime-link=static address-model=64
  6. Cut folder C:Program Filesoostoost_1_61_0stagelib and copy it to C:Program Filesoostoost_1_61_0lib.
  7. For the VC++ Console project you want to use these libraries, right click Properties > Linker > General > Additional Library Directories and add path C:Program Filesoostoost_1_61_0lib. For VC++ library projects you will find same setting in Properties > Librarian.

Now you are all set!

Note: Original question about not finding command prompt is addressed by answer from @Arnaud. Above are more clarified steps for Boost installation also step #5 below for more detail on command prompt.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...