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