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 followed the instructions from @jokerdino here in askubuntu

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7

But to get a successful compilation I've had to:

  1. export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
  2. sudo ln -s /usr/lib/x86_64-linux-gnu/crti.o /usr/lib64/crti.o
  3. sudo ln -s /usr/lib/x86_64-linux-gnu/crtn.o /usr/lib64/crtn.o

Which I understand effectively breaks the Ubuntu multilib model. So how do I compile the correct way and remove the links? Because now I'd like to cross-compile for 32 bits. (Using Precise)

share|improve this question
    
@jokerdino ping –  FEichinger Jan 3 '13 at 17:02

1 Answer 1

I removed the symbolic links posted in my question.

Then with @shuttle87's suggestion in askubuntu
I did the following:

sudo apt-get install --reinstall binutils  
sudo apt-get install --reinstall build-essential  
sudo apt-get install --reinstall libc6-dev  
sudo apt-get install --reinstall gcc-4.7-multilib   
sudo apt-get install --reinstall g++-4.7-multilib 

Then this worked: gcc -m32 foo.c
to compile for 80386.

But to compile for x86-64 gcc foo.c did NOT work.

So I tried:

 gcc foo.c -L /usr/lib/x86_64-linux-gnu

But that didn't work either. Finally had to:

export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

Before gcc foo.c would work.

I used "readelf -h" to verify that the executables were 80386 and X86-64.

Don't understand why the 'L' flag didn't work...

But at least I got those symbolic links removed and can cross-compile easily enough using the "export".

share|improve this answer
    
Note: when using CMake I didn't have to worry about exporting /usr/lib/x86_64. All I had to do was supply the "m=-m32" option when needed. –  Skippy VonDrake Jan 4 '13 at 14:49

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.