I think I dont have a c library in my ubuntu
I wrote a simple program to check if I cam compile c in my ubuntu. and I figure maybe I dont have it. am I right?
user@user-desktop:~/Desktop/s$ more ok.c #include <stdio.h> void main() { printf("hello world.\n"); exit(0); } user@user-desktop:~/Desktop/s$ make ok.c make: Nothing to be done for `ok.c'. user@user-desktop:~/Desktop/s$ ./ok bash: ./ok: No such file or directory user@user-desktop:~/Desktop/s$ gcc ok.c ok.c: In function ‘main’: ok.c:5: warning: incompatible implicit declaration of built-in function ‘exit’ ok.c:3: warning: return type of ‘main’ is not ‘int’ user@user-desktop:~/Desktop/s$ ./ok bash: ./ok: No such file or directory |
gcc ok.c -o ok
I.e. you have no 'Makefile', then the make command "has nothing to do". And to get the file 'ok' created, you must specify the file name. 'gcc ok.c' : will create 'a.out' : ./a.out : hello world. .. |
GNU make knows how to compile simple C programs without a makefile:
Code:
~/tmp/ok$ cat ok.c PS the warning is because you didn't #include stdlib.h which declares the exit function. |
All times are GMT -5. The time now is 10:25 PM. |