Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build Boost 1.64 in 64 bits?

Tags:

c++

boost

I am running Windows 10 and have Visual Studio 2017 Community Edition installed in my laptop. I have some older programs that compiled fine in VS 2015 with Boost 1.62.0 in 64 bits. For some very strange reason, I cannot find a way to compile say any library from Boost 1.64.0 (here filesystem and timer) using VS 2017 with this command line:

b2 --build-dir=..\build_here --with-filesystem --with-timer --address-model=64

The command will execute and the libraries will be built, but in 32 bits!!

What could be going wrong?

Regards, Juan Dent

like image 365
Juan Dent Avatar asked May 12 '17 21:05

Juan Dent


People also ask

How do I use Visual Studio code in Boost library?

Linking the Boost libraries on Visual Studio (Note: In case your project builds a static library, the “Linker” menu will be shown as “Librarian”.) Select the drop-down button and then click <Edit..>. Add the following value: C:\Program Files\boost\boost_1_76_0\bin\$(PlatformTarget)\lib , and hit OK.

Where do I put Boost?

Install Boost (Windows) Extract in a Boost folder located at C:\ or C:\Program files so that CMake find-modules can detect it. Invoke the command line and navigate to the extracted folder (e.g. cd C:\Boost\boost_1_63_0 ).


Video Answer


4 Answers

To update the answer I gave here. Visual Studio 2017 is a new toolset, so simply replace toolset=msvc-14.0 (for Visual Studio 2015) with toolset=msvc-14.1 i.e.:

In a Visual Studio tools Command Prompt:

cd boost_1_64_0
call bootstrap.bat

For static libraries (recommended for Windows):

b2 -j8 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=complete stage

Note: thread must be built with dynamic linking see: https://studiofreya.com/2015/05/20/the-simplest-way-of-building-boost-1-58-for-32-bit-and-64-bit-architectures-with-visual-studio/

To build thread in a dynamic library:

b2 -j8 toolset=msvc-14.1 address-model=64 architecture=x86 link=shared threading=multi runtime-link=shared --with-thread --build-type=minimal stage

Note: the correct b2 toolset for Visual Studio 2017 is msvc-14.1 not msvc-15.0 and
the b2 toolset for Visual Studio 2019 is msvc-14.2.
If in doubt (and you've only one version of Visual Studio installed) just use toolset=msvc.

like image 200
kenba Avatar answered Oct 30 '22 05:10

kenba


I don't know why, but the Boost is compiled with 32 bit same with the native x64 prompt of VS 2017.

This step-by-step worked for me:

  1. Open x64 Native Tools Command Prompt for VS 2017;
  2. Changed the boost_1_66_0\project-config.jam to:

    import option ; //Check your compiler path here: using msvc : 14.1 : "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64/cl.exe"; using mpi ; option.set keep-going : false ;

  3. Run:

    b2.exe --toolset=msvc-14.1 --address-model=64 --architecture=x86 --runtime-link=static,shared --link=static threading=multi --build-dir=build\x64 install --prefix="C:\Program Files\Boost" -j4

    or

    bjam.exe toolset=msvc-14.1 address-model=64 architecture=x86 runtime-link=static,shared link=static threading=multi build-dir=build\x64 install prefix="C:\Program Files\Boost" -j4

You should have a 64-bit = yes at the start of compilation.

like image 33
gilbriatore Avatar answered Oct 30 '22 07:10

gilbriatore


Try specifying architecture=ia64

e.g.

b2.exe --toolset=msvc-14.1 --address-model=64 --architecture=ia64 --runtime-link=static,shared --link=static threading=multi --build-dir=build\x64 install --prefix="C:\Program Files\Boost" -j4
like image 43
Michael Zhang Avatar answered Oct 30 '22 07:10

Michael Zhang


Consider saving a bunch of time by entering each boost version directory that you need and running there this:

bootstrap && b2 -a install

This way C:\Boost directory created with all possible combinations of library build options built including x64. You may want to turn this directory compression on.

like image 24
Sergei Krivonos Avatar answered Oct 30 '22 07:10

Sergei Krivonos