Question

I'm trying to build a specific program on Ubuntu 12.04 64 bit. The program needs to be compiled 32 bits.

I installed the ia32-libs and gcc-multilib packages.

I managed to compile it on 3 different computers, but on this one, it fails with a weird error. for some reason, libm.so is not picked up correctly, or something is wrong with the library.

This is the actual compilation line that fails as it was extracted from the Makefile.

gcc -o x86_32_obj/foo x86_32_obj/foomain.o -m32 -fPIC -fno-stack-protector -lc -lgcc -lm -lpthread -lrt -lstdc++ ../libfoo/lib/./libfii.x86_32.a

This is the output

/usr/bin/ld: ../libfoo/lib/./libfoo.x86_32.a(NK_Meas.o): undefined reference to symbol 'expf@@GLIBC_2.0'
/usr/bin/ld: note: 'expf@@GLIBC_2.0' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib32/libm.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib32/libm.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[1]: *** [foo] Error 2
make: *** [foo] Error 2
Was it helpful?

Solution 2

Found the problem. Apparently, the library file I was linking against was compiled using a different version of GCC. I don't know how exactly it's related, but once I replaced the gcc compiler to the one used with the library it worked.

OTHER TIPS

I have seen errors such as this in relation to the linking order. It may be possible to address the error by placing the libm linking directive at the very end of your linking configuration.

These interdependencies are very much system dependent, which is probably why the same command works on other systems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top