Reputation: 1157
I wrote a program in C.After I compiled it using
gcc -o pr prc.c
and I got the thing below
/usr/bin/ld:cannot find -lc
collect2: ld returned 1 exit status
Upvotes: 0
Views: 719
Reputation: 143017
The linker (ld
) can't find library file libc.{a|so}
, the standard C library. See the ld man page for mention of this library (and lc
command line option to ld
) under section OPTIONS. Quoting:
ld -o <output> /lib/crt0.o hello.o -lc
This tells ld to produce a file called output as the result of linking
the file "/lib/crt0.o" with "hello.o" and the library "libc.a"
You should check to make sure these files are actually missing from your system. On my Ubuntu 10.04 LTS system:
~ [88] locate libc.so
/lib/libc.so.6
/lib/tls/i686/cmov/libc.so.6
/usr/lib/libc.so
~ [89] locate libc.a
/usr/lib/libc.a
/usr/lib/xen/libc.a
How you install this missing library will vary based on your distribution. Use your package manage to search for libc
. Otherwise, you may want to consider re-installing gcc
Upvotes: 3
Reputation: 63707
-lc is an abbreviation of libc which is the C
run-time library. What ever your *nix distribution is, you need to install glibc and glibc-common through an appropriate installer.
man ld
and that should give an insight on the error message. Messages like these indicates that the linker is looking for a missing library. The Name of the library here is libc (replace l with lib).
Upvotes: 3