views:

1385

answers:

3

I've migrated an Oracle database and Oracle HTTP server install from a 32-bit machine to a 64-bit machine - both machines running Linux. Oracle Database is 64-bit, but the (Apache) HTTP server is 32-bit.

I use some non-Oracle DSOs (mod_ntlm for one) but whenever I run the standard "make install" type thing I end up with a 64-bit module.

Is there a standard way to compile 32-bit Apache modules on a 64-bit machine?

+3  A: 
./configure CFLAGS="-march=i686"

should do it

Andrew Medico
didn't work for me.
Seun Osewa
+4  A: 

As an alternative to Andrew Medico's answer, use '-m32' for 32-bit compilations and '-m64' for 64-bit compilations on PPC or SPARC or Intel machines - since you don't actually mention which chip architecture you are using and that notation works on all of these.

I often use:

CC="gcc -m32" ./configure

to ensure a 32-bit compilation (or, more frequently, CC="gcc -m64" to ensure 64-bit compilation).


Question: "Is CC an environment variable used by make?"

Answer: Yes, though in this case, it is also recognized by configure, which is a shell script generated by autoconf. The notation I used - which is what I use at the command line - sets CC in the environment while the configure command is run. The other answer suggests using:

./configure CC="gcc -m32"

I assume that works and achieves much the same effect; I've not tried it so I don't know that it works.

If you run ./configure --help | less, you will see information (often just standard information) about how to use the script. And at the end, it will list (some of the) relevant environment variables, of which CC is one.

The advantage of setting the C compiler to "gcc -m32" is that the 32-bit flag is set every time the compiler is used - there is very little room for it to go wrong. If you set a flags variable (CFLAGS, etc), there is a chance that some command won't use it, and then things can go awry.

Also, going back to the question, make certainly uses a variable (macro) called CC. And you can set that on the make command line:

make CC="gcc -m32"

That overrides any setting in the makefile. By contrast, using an environment variable, the setting in the makefile overrides the value in the environment, so setting CC as an environment variable is less helpful. Although make -e gives the environment precedence over the makefile, it is usually a dangerous option to use - it can have unexpected side-effects.

Jonathan Leffler
Thanks for the reply. Sorry to be dim, but where does this go? Is CC an environment variable used by make?
Nick Pierpoint
+2  A: 

Along with the -m32 flag in gcc, you may need to include the -melf_i386 flag for ld to properly link the 32bit object files to the 32bit libraries if you have both the 32bit and 64bit libraries. The standard ld on 64bit linux boxes will default to the 64bit libraries and you get a compatibility error when the linking occurs.

MichaelN