Compilation problems: cannot find crt1.o

I have a Debian virtual system that I use for development.

Today I wanted to try llvm / clang.

After installing clang, I can not compile my old c-projects (with gcc). This is mistake:

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

I removed clang and still did not work.

Does anyone know how I can fix this?

+81
gcc clang ld
Jun 13 '11 at 11:35
source share
17 answers

What helped me create a symlink:

 sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64 
+57
Jan 25 2018-12-12T00:
source share

For me

 aptitude install gcc-multilib 

solved a similar problem on Debian.

+51
Apr 15 '13 at 13:44
source share

It seems that when you played with llvm / clang, you (or the package manager) deleted the existing C standard library development kit ( eglibc in Debian) or you probably didn’t have it installed first, so you need to reinstall it now that you are back in gcc.

You can do it on Debian:

 aptitude show libc-dev 

Ubuntu:

 apt-get install libc-dev 

In Ubuntu, if you do not have libc-dev, since I cannot find it on packages.ubuntu.com, you can try installing libc6-dev directly.

Or on Redhat, as a system:

yum install glibc-devel

NB: although you were briefly answered in the comments, here is the answer, so there is one on the record if someone meets this and can find the answer, but not in the comments or the comment is not explicit enough for them.

+27
Jul 11 2018-11-11T00:
source share

This is a BUG reported in the launch pad, but there is a workaround:

Run this to see where these files are.

 $ find /usr/ -name crti* /usr/lib/x86_64-linux-gnu/crti.o 

then add this path to the variable LIBRARY_PATH

 $ export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH 
+24
May 17 '13 at 9:13
source share

If you are using a Debian testing version called "wheezy", you may have been bitten by switching to multi-archive. Read more about Debian multiarch here: http://wiki.debian.org/Multiarch

Basically, what happens is, various architecture-specific libraries are moving from traditional places in the file system to new architecture-specific places. This is why /usr/bin/ld confused.

Now you will find crt1.o in /usr/lib64/ as well as /usr/lib/i386-linux-gnu/ and you will need to talk about your toolchain. Here is some documentation on how to do this; http://wiki.debian.org/Multiarch/LibraryPathOverview

Note that simply creating a symbolic link will give you only one architecture, and you will essentially disable multi-archived. Although this may be what you want, it may not be the optimal solution.

+17
Jun 19 '12 at 12:56
source share

After reading the http://wiki.debian.org/Multiarch/LibraryPathOverview that jeremiah posted, I found the gcc flag that works without a symlink:

 gcc -B/usr/lib/x86_64-linux-gnu hello.c 

So you can just add -B/usr/lib/x86_64-linux-gnu to the CFLAGS variable in the Makefile.

+13
Sep 12
source share

As explained in the crti.o file , it is better to use "gcc -print-search-dirs" to find out the entire search path. Then create a link as described above "sudo ln -s" to point to the location of crt1.o

+5
Jan 22
source share

In order to get 64-bit RHEL 7 for compiling 32-bit gcc 4.8 programs, you need to do two things.

  • Ensure that all 32-bit gcc 4.8 development tools are fully installed:

     sudo yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686 
  • Compile programs using the -m32 flag

     gcc pgm.c -m32 -o pgm 

stolen from here: How to compile 32-bit applications on 64-bit RHEL? - I needed to do only step 1.

+5
Aug 15 '16 at 22:39
source share

Approach it in CentOs 5.4. Noticed that lib64 contains crt * .o files, but lib did not. Installed glibc-devel via yum, which set the i386 bits, and this solved my problem.

+1
Mar 20 '13 at 6:49
source share

Even I got the same compilation error when I cross-compiled i686-cm-linux-gcc.

The next compilation option solved my problem

 $ i686-cm-linux-gcc ac --sysroot=/opt/toolchain/i686-cm-linux-gcc 

Note. sysroot should point to the compiler directory where usr / include is available

In my case, the toolchain is installed in the / opt / toolchain / i 686-cm-linux-gcc directory, and usr / include is also available in the same directory

0
Aug 28 '13 at 9:12
source share

This worked for me with Ubuntu 16.04

 $ LIBRARY_PATH=/usr/lib/x86_64-linux-gnu $ export LIBRARY_PATH 
0
Mar 31 '17 at 7:07
source share

I had the same problem today, I solved it by installing the recommended packages: libc6-dev-mipsel-cross libc6-dev-mipsel-cross, libc-dev-mipsel-cross

This worked:

 sudo apt-get install libc6-dev-mipsel-cross 
0
Oct 11 '17 at 19:20
source share

./configure --disable-multilib

works for him

0
Dec 18 '17 at 11:34 on
source share

In my case, the crti.o error was related to the configuration of the execution path from Matlab. For example, you cannot execute a file if you have not previously set the path to the execution directory. To do this: File> setPath, add a directory and save.

-one
Apr 11 '13 at 15:35
source share

use gcc -B lib_path_containing_crt? .o

-one
Jul 29 '13 at 9:05 on
source share

I solved it as follows:

1) try to find the ctr1.o and ctri.o files with find -name ctr1.o

I got the following on my computer: $/usr/lib/i386-linux/gnu

2) Add this path to the PATH environment variable (also LIBRARY_PATH ) (to see which name: type env command is in the terminal):

 $PATH=/usr/lib/i386-linux/gnu:$PATH $export PATH 
-one
Apr 05 '15 at 22:44
source share

In my case of Ubuntu 16.04 I don't have crti.o at all:

 $ find /usr/ -name crti* 

So, I install libc 6 -dev package:

 sudo apt-get install libc6-dev 
-one
Oct 19 '16 at 11:24
source share



All Articles