26

When I want to make gcc 4.1.2 (ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.1.2/gcc-4.1.2.tar.bz2) on my ubuntu 12.04 (x86_64). The current active gcc is 4.6.2. I did:

./configure

then

make

However I get this error

/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: ld returned 1 exit status

Searching the web it seems that there is a problem with the location of crti. These files are available on the system

# find /usr/ -name crti*
/usr/lib32/crti.o
/usr/lib/x86_64-linux-gnu/crti.o
/usr/lib/debug/usr/lib/x86_64-linux-gnu/crti.o

Also the libc6 devel package is installed

# dpkg -l | grep libc6
ii  libc6                                  2.15-0ubuntu10.3                          Embedded GNU C Library: Shared libraries
ii  libc6-dbg                              2.15-0ubuntu10.3                        Embedded GNU C Library: detached debugging symbols
ii  libc6-dev                              2.15-0ubuntu10.3                        Embedded GNU C Library: Development Libraries and Header Files
ii  libc6-dev-i386                         2.15-0ubuntu10.3                        Embedded GNU C Library: 32-bit development libraries for AMD64
ii  libc6-i386                             2.15-0ubuntu10.3                        Embedded GNU C Library: 32-bit shared libraries for AMD64
ii  libc6-pic                              2.15-0ubuntu10.3                        Embedded GNU C Library: PIC archive library

How can I fix that?

UPDATE:

After adding these

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

That problem is solved. However now I get

/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.a when searching for -lc
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/x86_64-linux-gnu/crti.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/x86_64-linux-   gnu/crtn.o' is incompatible with i386 output
collect2: ld returned 1 exit status
1
  • I'm getting other errors, about makeinfo not being present, which is on my system. Can't get to your error with these steps.
    – gertvdijk
    Feb 6, 2013 at 18:34

4 Answers 4

18

This is a BUG reported in launchpad, byt there is a workaround :

compiling 64 bits program in 32 bits platform :

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

for 32 bits native :

LIBRARY_PATH=/usr/lib32:$LIBRARY_PATH
export LIBRARY_PATH

That in your .bashrc file (or ran from a console) is enough for GCC to find the new location of library.

thx. to Iain Buclaw (ibuclaw) to point out in the right direction.

12.10 32 bits

hhlp@hhlp:~$ sudo find /usr/ -name crti*
/usr/lib/i386-linux-gnu/crti.o
hhlp@hhlp:~$ 

LIBRARY_PATH=/usr/lib/i386-linux-gnu:$LIBRARY_PATH 
export LIBRARY_PATH

12.10 64 bits

hhlp@hhlp:~$ sudo find /usr/ -name crti*
/usr/lib/x86_64-linux-gnu/crti.o
hhlp@hhlp:~$ 

LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH 
export LIBRARY_PATH
5
  • That problem is solved. However new error I get. Please see the original post
    – mahmood
    Feb 6, 2013 at 19:10
  • 2
    Thanks but that wasn't the solution to the second problem. I found that I had to do ./configure --disable-multilib and rebuild from scratch according to gcc.gnu.org/ml/gcc-help/2009-05/msg00238.html Thanks for your help
    – mahmood
    Feb 6, 2013 at 20:05
  • Doesn't work with Ubuntu 16.04 and my build. Mar 21, 2017 at 12:24
  • I face the same issue, but while running make install as final step. I did set LIBRARY_PATH but to no avail!! Any help appreciated
    – faizan
    Jul 22, 2017 at 10:35
  • 1
    After using that I had the problem "Current directory should not be in LIBRARY_PATH` caused by a previously empty LIBRARY_PATH. Hence use export LIBRARY_PATH="/usr/lib/x86_64-linux-gnu${LIBRARY_PATH+:$LIBRARY_PATH}" or (if you know it is empty) export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
    – Flamefire
    May 14, 2018 at 14:23
6

In my case Ubuntu 16.04 the I have no crti.o at all:

$ find /usr/ -name crti*

So I install developer package:

sudo apt-get install libc6-dev
0

Building GCC 4.8 on x86-64 from upstream sources you run into the problem of needing to build both 32- and 64-bit libraries (unless multi-lib is disabled). In that case you need to add both paths /usr/lib/x86_64-linux-gnu and /usr/lib32.

1
  • By default yes. But you can restrict the build to only 64bit with the option --with-multilib-list=m64 for ./configure. It worked for me when I built GCC 4.8.5. I mentioned it also in my answer (part 3) on stackoverflow.com/a/55703805/4807875. Oct 2, 2019 at 16:38
0

I'm also building an older version of gcc on my Ubuntu machine (3.4.6 on a 4.6.3 machine)
I tried @mahmood's --disable-multilib solution, but then the package I needed to use gcc 3.4.6 also seemed to need the 32 bit library as well.

Thus I added both the 64 bit and 32 bit libraries to the LIBRARY_PATH

LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib32:$LIBRARY_PATH 
export LIBRARY_PATH 

Oh and I'm on Ubuntu 12.04 64bits

1
  • 1
    To work with older gcc/g++, you have to forget Ubuntu because on newer version of Ubuntu, you can not fully fix the problem and an older Ubuntu on the other hand is no longer supported. You have to use rehdat based systems. Centos 6.3 is ok
    – mahmood
    Jan 13, 2014 at 10:37

You must log in to answer this question.

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