Reputation: 18441
I am using cryptopp
on a Ubuntu 64bit machine. I need to compile the library for 32bit, but I cannot find out how.
Shall I make some change in the GNU Makefile or use an optional argument when calling make
?
Upvotes: 3
Views: 798
Reputation: 102205
Shall I make some change in the GNU Makefile or use an optional argument when calling make?
Everyone's answers should work for you. To be pedantic, the following will also work for Crypto++ 5.6.3 and above. It was added to CXXFLAGS
because its a compiler option:
export CXXFLAGS="-DNDEBUG -g2 -O2 -m32"
make static dynamic cryptest.exe
...
# Run validation suite
./cryptest.exe v
# Run test vectors
./cryptest.exe tv all
Crypto++ 5.6.2 used to use the following (from 5.6.2's GNUMakefile):
1 CXXFLAGS = -DNDEBUG -g -O2
2 # -O3 fails to link on Cygwin GCC version 4.5.3
3 # -fPIC is supported. Please report any breakage of -fPIC as a bug.
4 # CXXFLAGS += -fPIC
...
8 ARFLAGS = -cr # ar needs the dash on OpenBSD
9 RANLIB = ranlib
...
25 ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
26 CXX = g++
27 endif
...
Notice it unconditionally sets both CXX
and CXXFLAGS
. This bothered the hell out of me and some other users, so it was one of the first things we changed when Wei turned the library over to the community.
Crypto++ 5.6.3 and above changed that. The makefile attempts to honor everything the user provides, including CXX
, CXXFLAGS
, AR
, ARFLAGS
, etc (from 5.6.3's GNUMakefile):
1 # Base CXXFLAGS used if the user did not specify them
2 CXXFLAGS ?= -DNDEBUG -g2 -O2
...
14 AR ?= ar
15 ARFLAGS ?= -cr # ar needs the dash on OpenBSD
16 RANLIB ?= ranlib
...
49 # We honor ARFLAGS, but the "v" often option used by default causes a noisy make
50 ifeq ($(ARFLAGS),rv)
51 ARFLAGS = r
52 endif
...
The same principles apple to GNUmakefile-cross
if you are performing cross-compiles for embedded and mobile platforms.
Upvotes: 1
Reputation: 7386
gcc
and g++
have a specific option to force to compile in 32bit mode, it is -m32
. So, if the Makefile system of your application is properly set, you just need to run the compilation as follow:
$> CXX='g++ -m32' make
That should be enough.
Upvotes: 4
Reputation: 1
You could try building it with make CC='gcc -m32' CXX='g++ -m32'
but you'll probably need several 32 bits libraries.
You could also set up a 32 bits distribution in a chroot
-ed environment (using debootstrap
) and build your crypto++
inside.
Upvotes: 5