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.

Right now I am having difficulties linking a project I am working on with gcc4.6 in ubuntu 11.10. Before the distribution upgrade everything linked fine and it still compiles/links on the other developers machines.

Currently the compile succeeds then the linking fails with the following:

/usr/bin/ld: error: cannot open crt1.o: No such file or directory
/usr/bin/ld: error: cannot open crti.o: No such file or directory
/usr/bin/ld: error: cannot open crtn.o: No such file or directory
collect2: ld returned 1 exit status
make: *** [mc] Error 1

Here's some info on what I am using:

$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) 

$ ldd --version
ldd (Ubuntu EGLIBC 2.13-20ubuntu5) 2.13
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

$ find /usr -name "crt1.o"
/usr/arm-linux-gnueabi/lib/crt1.o
/usr/lib32/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o
/usr/lib/debug/usr/lib32/crt1.o
/usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o
/usr/arm-linux-gnueabihf/lib/crt1.o

Happy to post any other info as needed!

share|improve this question
    
try to install this sudo apt-get libc6-dev –  hhlp Oct 22 '11 at 16:14
    
@hhlp, I have done this and it still doesn't work. My problems may be from broken packages. –  shuttle87 Oct 23 '11 at 9:22
add comment

5 Answers

up vote 2 down vote accepted

It seemed as though all of the requisite .o files were installed but the ppa version of gcc 4.6 I had was looking in the wrong place for them. Reinstalling all of the packages from the official oneric repo's solved the problem.

Make sure you have access to the correct repositories then:

sudo apt-get update
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.6
sudo apt-get install --reinstall libboost1.46-all-dev
share|improve this answer
add comment

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

share|improve this answer
add comment

Either you try to install an older version of gcc which was the first suggestion that I got on my own question on such a problem or take a look at the answer that I got from David Puglielli which explains the causes for that problem ( Why does gsl-library not compile/link in 11.10, despite that it did under 11.04 with the same makefile and program? ). His answer helped me and I hope it does so for you.

share|improve this answer
add comment
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu 

Was the trick that worked for me on Kubuntu 11.10 and Ubuntu 12.04

share|improve this answer
add comment

I was having a similar problem linking a file needing the -lpthread flag. I was trying:

gcc -lpthread filename.c

when apparently this new version (which I found out thanks to cuichi) automatically executes some kind of flag in which it matters the order of commands you input. So changing it to:

gcc filename.c -lpthread 

finally worked.

share|improve this answer
add comment

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.