Building a 32-bit application in 64-bit Ubuntu

After several hours of working on the Internet, I decided to refuse you and ask you experts. I am trying to create a 32-bit application (xgap if you are interested) in my 64 Ubuntu 11.10. I added CFLAGS = -m32 and LDFLAGS = -L / usr / lib32 to make . Objects are embedded in 32-bit tone. The last step is to link all the objects and libraries for X windows into this executable --- xgap. Somehow he continues to give me this error:

gcc -o xgap xcmds.o utils.o gapgraph.o gaptext.o pty.o popdial.o xgap.o selfile.o -L/usr/lib32 -lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE /usr/bin/ld: skipping incompatible /usr/lib32/libXmu.so when searching for -lXmu ... /usr/bin/ld: i386 architecture of input file `xcmds.o' is incompatible with i386:x86-64 output ... 

I installed ia32-libs and mutilib support . I think I just need to get the linker to generate i386 output. I tried putting two ld in my gcc command as shown above: -melf_i386 and -oformat elf32-i386 . But what happens is that gcc no longer searches for the 32-bit library in / usr / lib32 . I wonder if these flags need to be set in a specific order?

Thanks for any idea and help!

EDIT : when I add the -m32 flag in my last gcc command (at the build stage, I reckon), even if I have the -L / usr / lib32 flag, gcc doesn't look in / usr / lib 32 anymore (really weird ...) and generates the following error:

 /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../libXaw.so when searching for -lXaw /usr/bin/ld: skipping incompatible /usr/lib/libXaw.so when searching for -lXaw /usr/bin/ld: cannot find -lXaw collect2: ld returned 1 exit status 

Anyone have an idea why this is happening? I use an automatic tool for customization and creation. I really know how to modify these script files.

+6
gcc 32bit-64bit ld
Dec 07 '11 at 19:15
source share
2 answers

You also need to use the link with -m32 .

 gcc -m32 -o xgap xcmds.o utils.o gapgraph.o gaptext.o pty.o popdial.o xgap.o selfile.o -L/usr/lib32 -lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE 

All things discussed, I think you should leave -L/usr/lib32 when using -m32 .

+5
Dec 07 '11 at 19:24
source share

I solved the problem. I think gcc was expecting a static library archive. I used the getlibs script from http://ubuntuforums.org/showthread.php?t=474790 to download all the .a archives needed for communication. Then gcc worked. I think gcc did a search in the / usr / lib32 directory , but did not find the .a archives, so I continued to search in the standard directory which is / usr / lib , where it finds incompatible files *. so .

But then the question arises: files *. so in / usr / lib32 / from the ia32-libs package are there really no libraries needed for communication? What files are used in / usr / lib32 / for?

+1
Dec 08 '11 at 3:40
source share



All Articles