1

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)

1
  • @jokerdino ping
    – user98085
    Jan 3, 2013 at 17:02

1 Answer 1

2

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".

1
  • 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. Jan 4, 2013 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .