Reputation: 899
I've got a proprietary program that I'm trying to use on a 64 bit system.
When I launch the setup it works ok, but after it tries to update itself and compile some modules and it fails to load them.
I'm suspecting it's because it's using gcc and gcc tries to compile them for a 64 bit system and therefore this program cannot use these modules.
Is there any way (some environmental variables or something like that) to force gcc to do everything for a 32 bit platform. Would a 32 bit chroot work?
Upvotes: 76
Views: 92634
Reputation: 4029
For any code that you compile directly using gcc
/g++
, you will need to add -m32
option to the compilation command line, simply edit your CFLAGS
, CXXFLAGS
and LDFLAGS
variables in your Makefile
.
For any 3rd party code you might be using you must make sure when you build it to configure it for cross compilation. Run ./configure --help
and see which option are available. In most cases you can provide your CFLAGS
, CXXFLAGS
and LDFLAGS
variables to the configure script. You also might need to add --build
and --host
to the configure script so you end up with something like
./configure CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 --build=x86_64-pc-linux-gnu --host=i686-pc-linux-gnu
If compilation fails this probably means that you need to install some 32 bit development packages on your 64 bit machine
Upvotes: 10
Reputation: 2116
You may get a 32-bit binary by applying Alan Pearce's method, but you may also get errors as follows:
fatal error: bits/predefs.h: No such file or directory
If this is the case and if you have apt-get, just install gcc-multilib
sudo apt-get install gcc-multilib
Upvotes: 53
Reputation: 1350
You need to make GCC use the -m32
flag.
You could try writing a simple shell script to your $PATH
and call it gcc (make sure you don't overwrite the original gcc, and make sure the new script comes earlier in $PATH
, and that it uses the full path to GCC.
I think the code you need is just something like /bin/gcc -m32 $*
depending on your shell (the $*
is there to include all arguments, although it might be something else – very important!)
Upvotes: 84