Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using gcc to compile a C++ application on my CI server (http://ci.berboe.co.uk) and as the vps that it is compiled on has the x86-64 architecture I need to cross-compile to get the compiled program to work on x86 computers.

I have installed gcc-multilib and g++-multilib and several other packages that were suggested in other places, but I still get an error when trying to compile. It is:

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

Full logs are available here: http://ci.berboe.co.uk/job/MCServer%20Linux-x86/11/console

Any help towards resolving this issue would be much appreciated.

Edit:

/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crti.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtbegin.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtend.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crtn.o' is incompatible with i386 output
/usr/bin/ld: final link failed: Invalid operation

I get this after having fixed the previous problem.

share|improve this question

3 Answers 3

up vote 2 down vote accepted
+50
  • Install 32 bits libs (ia32-libs in some distros, moving to this: http://wiki.debian.org/Multiarch/HOWTO in others, more on that if you ask for it).
  • Be sure to add the i386 library path to your LD_LIBRARY_PATH env. variable. (most certainly export LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/lib32:/usr/lib32:/usr/lib/i386-linux-gnu and so one).
  • Be sure to add the i386 include path to your LD_INCLUDE_PATH environment variable.

Feel free to look for these libraries (once installed of course), using:

find / -iname "*libstdc++.so*" 2> /dev/null

for instance for the libstdc++.so library. find should report some path that you will be able to add to your LD_LIBRARY_PATH environment variable.

share|improve this answer
    
I installed the package, but the compilation still does not work. I tried adding the LDLIBPATH to the .bashrc and then putting it right before and doing a manual make, and it still didn't work. –  bearbin Feb 6 '13 at 20:43
    
export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/lib32:/usr/lib32:/usr/lib/i386-linux-gnu –  bearbin Feb 7 '13 at 17:49
    
This is the error: /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a when searching for -lstdc++ And the command shows locations in /lib32 and /usr/lib32 so it should work. –  bearbin Feb 9 '13 at 8:01
    
The problem is, I have. The C++ args are: -m32 -s -g -O3 -DNDEBUG. –  bearbin Feb 9 '13 at 20:35
    
Thanks so much! One symlink was all it took! –  bearbin Feb 10 '13 at 12:27

There are two options that might work:

  1. Install ia32-libs package by running sudo apt-get install ia32-libs . It is just a hunch, it might or it might not work.
  2. Another solution can be to install a 32-bit linux on a virtual machine to compile the code.

This link might help: - http://en.sfml-dev.org/forums/index.php?topic=6034.0

share|improve this answer

You'd be better off making an i386 chroot. mk-sbuild (in ubuntu-dev-tools) and schroot make these very easy to manage.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.