linking an application built with -m32 flag
Posted on 2006-04-20
I'm building an application on RedHat Enterprise 3 for x86-64. I'm running the 64 bit kernel and compilers, but right now I need to build a 32 bit app. I added the -m32 flag to my make files and it sure looks like 32 bit code is being generated. However, when it comes time to link in the library I'm told that it's not compatible. I figure I'm either missing a flag for ar or for ld. I don't really know what to pass them and the man pages are so huge I figured it would be faster just to ask someone.
Here is a brief transcript of my problem:
[bottiger@rubicant ipm]$ make
g++ -D_DEBUG -DLINUX -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DRTI_USES_STD_FSTREAM -D__linux__ -Wno-deprecated -m32 -O -Dlinux \
-c ipm.cpp -o linux/ipm.o
ar -rc /opt/itt/ipm/lib/linux/libipm.a linux/ipm.o
At this point, it is my understanding that the 32 bit library has been built, and that I shoud be able to build my app with the -m32 flag and statically link it.
[bottiger@rubicant example]$ make
cd client; make
make: Entering directory `/home/bottiger/development/ipm/dev4/src/example/client'
echo in the .o maker
in the .o maker
g++ -I/opt/itt/ipm/src/include -Dlinux -O -exceptions -D_DEBUG -DLINUX -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DRTI_USES_STD_FSTREAM -D__linux__ -Wno-deprecated -m32 \
-c client.cpp -o linux/client.o
-lm -lipm \
/usr/bin/ld: skipping incompatible /opt/itt/ipm/lib/linux/libipm.a when searching for -lipm
/usr/bin/ld: cannot find -lipm
collect2: ld returned 1 exit status
make: *** [/opt/itt/ipm/bin/linux/client] Error 1
make: Leaving directory `/home/bottiger/development/ipm/dev4/src/example/client'
make: *** [CLIENT] Error 2
I'm betting my problem is with ar, but I'm a total novice with it, so I'm pretty well stuck.