32-bit and 64-bit Binaries Supported on Linux?

Nov 7, 2014 at 3:25 AM
Casablanca has been working great on 32/64-bit Windows and 64-bit Linux. Is there support for building 32-bit binaries on 64-bit Linux? Is there a Makefile setting for 32-bit builds on 64-bit Linux?
Nov 7, 2014 at 8:00 PM

Yesterday I posted how to build 64-bit Casablanca from the ground up on Linux, here:


You can probably get it to work by modifying those instructions and building your own Boost from source. To build a 32-bit Debug Boost:

./bin/b2 --toolset=gcc address-model=32 --stagedir=./stage32debug --build-dir=./build32debug --layout=system --without-mpi variant=debug link=shared threading=multi runtime-link=shared install --prefix=./linux32debug/indep --exec-prefix=./linux32debug/bin --libdir=./linux32debug/lib --includedir=./linux32debug/include

Release is:

./bin/b2 --toolset=gcc address-model=32 --stagedir=./stage32release --build-dir=./build32release --layout=system --without-mpi variant=release link=shared threading=multi runtime-link=shared install --prefix=./linux32release/indep --exec-prefix=./linux32release/bin --libdir=./linux32release/lib --includedir=./linux32release/include

You can then try and trick the regular CMake build into doing a 32-bit compile:

CXX="g++ -m32" cmake .. -DBOOST_ROOT=/path/to/your/boost_1_56_0/linux32debug -DCMAKE_BUILD_TYPE=Debug


CXX="g++ -m32" cmake .. -DBOOST_ROOT=/path/to/your/boost_1_56_0/linux32release -DCMAKE_BUILD_TYPE=Release

You're telling CMake that CXX is the g++ compiler with the 32-bit flag set all in one. This might not work but it's easy to try out.

Nov 7, 2014 at 9:04 PM
Damien has the right idea here, though if you want to do a 32-bit cross compile, you'll need to also make sure that you're linking against a 32-bit copy of OpenSSL and libiconv. It may be useful to look through our Android instructions, which is also a cross-compilation.

Nov 7, 2014 at 9:07 PM
It may be easier to simply set up a 32-bit chroot environment and build everything natively. This is a somewhat advanced topic so we won't be able to provide any help with that, but it should work.

Nov 8, 2014 at 1:09 PM
I like @roschuma's simple suggestion about using a 32-bit system. However, a complication is that the build/test/release system is RHEL 7 which does not have a 32-bit distro, nor does its sister CentOS 7. I could try building on 32-bit Ubuntu and moving over the files. Or I could try @damienhocking build procedure. Neither approach is transparent. I'm going to revisit our requirements and see if we can work around the need for 32-bit. The issue, of course, arises because of a legacy situation.
Nov 10, 2014 at 4:25 PM
Many of the big Linux distributions are phasing out 32-bit support. If you can get around having to do 32-bit at all, you'll be saving yourself pain in the long run.

Dec 1, 2014 at 4:46 AM
Edited Dec 1, 2014 at 9:47 PM
I have successfully built a 32-bit version of C++ Rest SDK v2.3 on RHEL 7 64-bit. It was easier than expected as I was able to use pre-built packages. Here's what I did.

Step 1: Install 32-bit boost and openssl. I used the pre-built packages in the RHEL 7 repository. If you need a newer version of boost or openssl, you'll have to build from source. @damienhocking above post may be correct or a good starting point for source building.
sudo yum install boost-devel.i686
sudo yum install openssl-devel.i686
sudo yum update
Step 2: Build a 32-bit version of C++ Rest SDK. The method is quite similar to building the default size.
cd casablanca/Release
mkdir build.release32
cd build.release32
CXX="g++ -m32" cmake .. -DCMAKE_BUILD_TYPE=Release
Step 3: Test the build. All tests should pass.
cd Binaries
./test_runner *.so
Step 4: Build your program. When you build or execute your program, be very careful to specify the correct LD_LIBRARY_PATH. You may need to specify both 32 and 64 bit directories. Be sure to specify either -m32 or -m64 on the g++ commands to force compilation using the desired bittedness. For example:
g++ t.cpp -m32 -O2 -pthread -march=native -std=c++11 -I /home/casablanca/Release/include -L /home/casablanca/Release/build.release32/Binaries -lcpprest
export LD_LIBRARY_PATH=/home/casablanca/Release/build.release32/Binaries
Marked as answer by BSalita on 11/30/2014 at 8:54 PM