Boost logo

Boost Users :

Subject: Re: [Boost-users] 32- and 64-bit builds on same machine
From: Andrew Holden (aholden_at_[hidden])
Date: 2010-08-13 10:32:52


On Friday, August 13, 2010 9:53 AM, Johan Råde wrote:
>
> What is the most convenient way to build Boost if I need both 32- and 64-bit
> builds on the same Windows machine?

I used the following batch file (Apologies if Outlook lie wraps it. It should have 6 lines):

------Begin Batch file------

Rem Visual Studio 2010

.\bjam --build-dir=C:\boost_intermediate --prefix=C:\boost64 toolset=msvc-10.0 address-model=64 link=static runtime-link=static,shared threading=multi variant=debug,release embed-manifest=on --without-python --without-mpi -sBZIP2_SOURCE="C:\bzip2-1.0.4" -sZLIB_SOURCE="C:\zlib123" install

.\bjam --build-dir=C:\boost_intermediate --prefix=C:\boost toolset=msvc-10.0 address-model=32 link=static runtime-link=static,shared threading=multi variant=debug,release embed-manifest=on --without-python --without-mpi -sBZIP2_SOURCE="C:\bzip2-1.0.4" -sZLIB_SOURCE="C:\zlib123" install

Rem Visual Studio 2008

.\bjam --build-dir=C:\boost_intermediate --prefix=C:\boost64 toolset=msvc-9.0 address-model=64 link=static runtime-link=static,shared threading=multi variant=debug,release embed-manifest=on --without-python --without-mpi -sBZIP2_SOURCE="C:\bzip2-1.0.4" -sZLIB_SOURCE="C:\zlib123" install

.\bjam --build-dir=C:\boost_intermediate --prefix=C:\boost toolset=msvc-9.0 address-model=32 link=static runtime-link=static,shared threading=multi variant=debug,release embed-manifest=on --without-python --without-mpi -sBZIP2_SOURCE="C:\bzip2-1.0.4" -sZLIB_SOURCE="C:\zlib123" install

------End Batch file------

This will create two target folders: C:\boost, which contains the 32-bit libraries and header files, and c:\boost64, which contains the 64-bit libraries and headers.

Obviously, you may need to tweak it for your needs. Begin by adding or removing toolsets to match your environment. Each toolset needs a pair of bjam lines. I have set the following options in each line:

--build-dir: The directory with the intermediate files. Not necessary, but I like to keep them out of the source directory. If you use this, don't point it to the boost source directory. I can't remember if you need to create this directory manually, or if boost build will do it for you.

--prefix: The directory into which boost will be installed. The 32-bit and 64-bit variants MUST have different prefixes. If you install multiple versions of boost or target multiple toolsets, they can all go into the same pair of prefixes without conflict.

toolset: the version of Visual Studio, mingw, or other compiler to target.

address-model: should be self-explanatory

link: Whether to build static or dynamic boost libraries. By default, Windows programs use the static libraries. Only change this if you really want the shared libraries.

runtime-link: Produce boost libraries that link against both the static and shared runtime libraries. You can change this if you know you will always use the same runtime library.

threading: Visual Studio hasn't shipped with a single-threaded runtime library in years. Don't change this.

variant: I strongly recommend you leave this alone.

embed-manifest: I can't remember what this one does.

--without-python: I don't use python, and got tired of seeing the warnings.

--without-mpi: Same for MPI.

-sBZIP2_SOURCE: I do use the bzip2 filters with iostreams. Delete this option if you don't. If you do use bzip2, there is no need to build it; just unzip the source and point this option to it.

-sZLIB_SOURCE: Same for zlib.

install: I want to install boost to the prefix directory.

After you get boost installed, you can delete the directory specified by --build-dir. I kept the source directory around so I have documentation, but you really only need to keep c:\boost and c:\boost64.

> I could of course install two separate copies of the entire Boost source tree,
> and build one from the 32-bit Visual studio command prompt, and the other from
> the 64-bit Visual Studio command prompt. But that seems a bit wasteful.

There is no need to use the "Visual Studio" command prompts. Boost Build will find them itself.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net