Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22145

How do I resolve this error 'cannot find -lc'?

$
0
0

How do I compile this code in CentOS 7 ? I am reading one book and in the book they use -static while compiling so that's how I did it and I get errors I mentioned below but when I dont use -static I get no errors and it compiles successfully.

First attempt:

main(){        exit(0);}

I get this error when I try to compile it.

$ gcc -static -o exit exit.cexit.c: In function _main_:exit.c:3:9: warning: incompatible implicit declaration of built-in function _exit_ [enabled by default]         exit(0);         ^/usr/bin/ld: cannot find -lccollect2: error: ld returned 1 exit status

Second attempt:

Then I google this error and lots of articles told me to include stdlib.h library so I did that as well and I get this error:Code:

#include <stdlib.h>main(){        exit(0);}

Now when I compile it, I get following error.

$ gcc -static -o exit exit.c /usr/bin/ld: cannot find -lccollect2: error: ld returned 1 exit status

linux version:

$ uname -aLinux localhost.localdomain 3.10.0-1127.13.1.el7.centos.plus.i686 #1 SMP Thu Jun 25 16:59:06 UTC 2020 i686 i686 i386 GNU/Linux

Viewing all articles
Browse latest Browse all 22145

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>