18

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

Juan Dent
  • 439
  • 2
  • 6
  • 14
  • 3
    For Visual Studio, you can skip this whole build step and just [get the binaries directly](https://sourceforge.net/projects/boost/files/boost-binaries/1.64.0/) – PaulMcKenzie May 12 '17 at 21:22
  • 1
    If you get the binaries you need 14.1 x64 for Visual Studio 2017 64 bit. – drescherjm May 12 '17 at 21:45
  • Here is the command I used to build boost 1.60 for VS2013 x64 : ***X:/Other/Libraries/boost_1_60_0/bjam.exe -j%NUMBER_OF_PROCESSORS% --without-python --without-mpi address-model=64 --build-dir=X:/x64.13/VC.120/Libraries/Boost-1.60.0/build --prefix=X:/x64.13/VC.120/Libraries/Boost-1.60.0 --toolset=msvc-12.0 --build-type=complete stage install*** – drescherjm May 12 '17 at 21:47
  • ***The command will execute and the libraries will be built, but in 32 bits!!*** Maybe you need to execute that from a Visual Studio 2017 x64 command prompt. I always build from the correct command prompt for 32 or 64 bit for the same version of the compiler I am targeting. – drescherjm May 12 '17 at 21:49
  • @drescherjm you are correct: the libraries are built but in 32 bits!!! Even when using the x64 command prompt... What now? – Juan Dent May 12 '17 at 22:05
  • 2
    There was a specific problem with VS2017, they could not get bjam going. It certainly is quite hard to do. That was recent, somewhat doubtful they fixed it. Yes, download the prebuilt binaries. – Hans Passant May 12 '17 at 22:09
  • Did you clean the build folder between tries? – drescherjm May 12 '17 at 22:09
  • You can also use the Nuget Package for 14.1 instead. – Christopher Pisz May 12 '17 at 22:13
  • Thanks @HansPassant, will try this first! – Juan Dent May 12 '17 at 22:27
  • @ChristopherPisz where can I download the Nuget Package? – Juan Dent May 12 '17 at 23:51
  • I expect that you download it directly in Visual Studio. – drescherjm May 13 '17 at 18:38
  • https://www.google.com/search?q=How+to+use+Nuget+in+Visual+Studio&oq=How+to+use+Nuget+in+Visual+Studio&aqs=chrome..69i57j0l5.6055j0j8&sourceid=chrome&ie=UTF-8 – Christopher Pisz May 14 '17 at 00:17
  • @HansPassant do you know if they fixed it yet? – Juan Dent May 22 '17 at 23:06

4 Answers4

24

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.

kenba
  • 4,303
  • 1
  • 23
  • 40
  • It was a helpful answer but where did you find documentation for the additional properties address-model and architecture? It isn't shown in the output of b2 --help as a property or option. I have yet to find it in the official boost build documentation either. – shawn1874 May 10 '22 at 19:44
  • 1
    @shawn1874 they are defined here: https://www.boost.org/doc/libs/1_79_0/tools/build/doc/html/index.html#bbv2.overview.builtins.features in the boost b2 user manual, – kenba May 11 '22 at 07:09
5

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.

gilbriatore
  • 658
  • 7
  • 12
1

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
Michael Zhang
  • 21
  • 1
  • 2
1

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.

Sergei Krivonos
  • 4,217
  • 3
  • 39
  • 54