20

How do I force a 32-bit build of Boost with GCC? Currently attempting by putting this line in my user-config.jam, but it does not work:

using gcc : 4.1.2 : g++ : compileflags="-m32" ;
Smi
  • 13,850
  • 9
  • 56
  • 64
Crazy Chenz
  • 12,650
  • 12
  • 50
  • 62
  • To build it using bjam, I think you'd do this: bjam address-model=32 architecture=x86 – waterlooalex Aug 31 '09 at 15:02
  • Is this on a Linux system…? I generally cheat by using `setarch i686 make` or similar. I don't know if that'd work for Boost, particularly, though. (And, in that case, you could just download the 32-bit binary for your OS, so I'm guessing perhaps you're on another system.) – BRPocock Jan 19 '12 at 23:03

2 Answers2

25

If you are using C++ Boost 1.40, use:

bjam address-model=32

If you are using eariler version, consider upgrading. If you cannot, use

bjam address-model=32 architecture=x86

I also recommend that you take a look at the fine manual

Vladimir Prus
  • 4,600
  • 22
  • 31
  • 12
    Oh yeah... that "fine manual" is great. I love all the examples they provide. (Sarcasm) – Crazy Chenz Sep 17 '09 at 13:21
  • 1
    Patches are welcome. However, I am not exactly sure that explicitly adding a full command like example for every single property listed at the above URL will do much other than bloating the size of docs. – Vladimir Prus Sep 18 '09 at 07:38
  • 2
    Note that if you have a 64 bits version of `gcc`, you should take a look at @AndrewMeadows answer. – ereOn Oct 04 '11 at 08:04
  • Using Boost 1.44 on OS X 10.6.8, I still find it necessary to specify `architecture=x86`. – JWWalker Jun 04 '12 at 23:04
  • Even for Boost 1.49.0 I had to use the architecture=x86 flag to get this to work on Mac OS X 10.8. – Bleyddyn Nov 06 '12 at 20:06
22

This answer helped me toward a solution that worked for me. I was trying to compile a 32-bits version of boost_1_43_0 on 64-bits debian and eventually came up with this:

./bjam                 \
  cflags=-m32          \
  cxxflags=-m32        \
  address-model=32     \
  threading=multi      \
  architecture=x86     \
  instruction-set=i686 \ 
  stage
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
Andrew Meadows
  • 221
  • 2
  • 2
  • 1
    In addition, if you want to change the compiler, you can specify your compiler version via the boost directory's 'project-config.jam' or 'user-config.jam' by making sure that `using gcc : : g++-4.4 ; ` is used (specified 4.4 for compiling Boost with Matlab MEX (32-bit) files on 64-bit linux). – eacousineau Oct 10 '12 at 04:32
  • Thanks Andrew, very usefull answer ! – Axel Borja Nov 24 '15 at 14:41