C ++ Build Environment using MinGW-w64 and Boost.Build

I am currently migrating one of my projects to GCC, and I am using the MinGW-w64 project to accomplish this, since I require both x64 and x86 support.

However, I ran into a problem setting up my build environment. My project currently uses the Boost C ++ libraries, and to simplify the build process, I also use Boost.Build in my project (as this simplifies integration).

In MSVC, this is fine, because I can do the following from the command line:

b2 toolset=msvc address-model=32 # compile as 32-bit b2 toolset=msvc address-model=64 # compile as 64-bit 

MinGW-w64 makes this "problematic" because 32-bit and 64-bit toolchains are placed in separate directories. (C: \ MinGW32 and C: \ MinGW64 respectively).

Is it possible to set Boost.Build so that it selects the correct toolchain based on the address model flag? If not, what is my next best option?

EDIT:

If this helps, I use rubenvb 4.6.3-1 assemblies from the MinGW-w64 website in the "Personal Builds" folder (I use these assemblies, in particular, since I want to try to parse my code) but not compile - under Clang) .

EDIT:

One solution that I was just thinking about would be β€œmanual” for PATH to point to the correct toolchain before compiling, however this adds an extra level of complexity to my build process that I would like to avoid. Ideally, I would like it to be as simple as it would be for MSVC, although I understand that it may not be possible. In the worst case, I assume that what I just suggested will work, and I just need to add scripts to set PATH correctly before calling Boost.Build. That would mean a hardcoding path, although I don't want to do ...

+7
source share
3 answers

Yo can make any Boost.Build toolbox selected based on the set of corresponding properties by adding a toolbox requirement (with the toolset.add-requirements rule). Some tools have built-in support, for example darwin.jam (Xcode), but unfortunately we have not added it to the gcc toolkit yet. But when declaring toolkits, you can use the same minimal code in your user-config.jam . It might look like this for you:

 import toolset ; using gcc : gcc-4.6.3~32 : /path/to/32bit/mingw/gcc ; using gcc : gcc-4.6.3~64 : /path/to/64bit/mingw/gcc ; # Add a global target requirements to "choose" the toolset based on the address model. toolset.add-requirements <toolset>gcc-4.6.3~32:<address-model>32 ; toolset.add-requirements <toolset>gcc-4.6.3~64:<address-model>64 ; 

This leads to the addition of this conditional requirement to all objectives. Which affects the selection of a specific goal for a specific declared toolkit as necessary.

.. I forgot to mention .. That even when creating two different declarations, the default toolbox is still selected dynamically. You can use the usual command line:

 b2 toolset=gcc address-model=64 

To use the 64 bit mingw compiler.

+5
source

Since MinGW binaries have different names, you can include the stand catalogs in the path, and then add two different sets of tools to the jam configuration file, where you specify the exact names of the binary files (excluding the path).

In the configuration file, add the following based on the format

using gcc: [version]: [C ++ - compile-command]: [compiler options];

 using gcc : 32 : mingw-w32-1.0-bin_i686-mingw ; using gcc : 64 : mingw-w64-1.0-bin_i686-mingw ; 

Then you can call b2 as follows:

 b2 toolset=gcc-32 bt toolset=gcc-64 
+3
source

MinGW-w64 can create 32 and 64 bit binaries.

I use tdm-mingw with the mingw64 tool and pass only -m32 or -m64 to the linker / compiler to select the version. In binaries, 64 bits are built by default.

0
source

All Articles