11
votes

I have one problem compiling gcc 4.6.2 under ubuntu 11.10. The error is quite popular i.e. /usr/bin/ld: cannot find crti.o: No such file or directory I tried to LIBRARY_PATH=/usr/lib/x86_64-linux-gnu where crti.o could be found by the linker but then the configuration complains that LIBRARY_PATH should not contain the path of the current directory when building gcc

checking LIBRARY_PATH variable... contains current directory
configure: error: 
*** LIBRARY_PATH shouldn't contain the current directory when
*** building gcc. Please change the environment variable
*** and run configure again.
make[2]: *** [configure-stage2-gcc] Error 1
make[2]: Leaving directory `/home/abdul/cc02/gcc-4.6.2/src-infra/obj-gcc'
make[1]: *** [stage2-bubble] Error 2
make[1]: Leaving directory `/home/abdul/cc02/gcc-4.6.2/src-infra/obj-gcc'

I have also tried to set LD_LIBRARY_PATH but no avail.

Thanks in advance.

4
Thanks @larsmans for proper editing my question.Shahzad
What does env | grep '^LIBRARY_PATH=' report?Fred Foo
IBRARY_PATH=/usr/lib/x86_64-linux-gnu/:Shahzad

4 Answers

32
votes

Apparently, your LIBRARY_PATH ends in a colon:

/usr/lib/x86_64-linux-gnu/:
#  -----------------------^

Get rid of that:

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

Combining the answers of @hmb, @FredFoo, and avoiding assumptions about users' systems:

It seems your LD_LIBRARY_PATH ends with a colon, which GCC doesn't approve of. You should also ensure C_INCLUDE_PATH doesn't end with a colon to avoid related issues. Here's how to do it:

export LIBRARY_PATH=$(echo $LIBRARY_PATH | sed 's/:$//; s/^://;')
export C_INCLUDE_PATH=$(echo $C_INCLUDE_PATH | sed 's/:$//; s/^://;')

then re-configure the build (with configure -v).

1
votes

I had the same problem and found a solution at askubuntu.

Especially in the following comment:

And, if you don't like patching your sources, and setting flags aren't working for you, just soft-link crt*.o into the /usr/lib dirctory (you'll find them in either /usr/lib/i386-linux-gnu or /usr/lib/x86_64-linux-gnu). – ams Nov 15 '11 at 14:55

0
votes

Following command solved problem

unset LIBRARY_PATH; ./configure -v