LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2011, 09:54 AM   #1
SharonGe
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu
Posts: 10

Rep: Reputation: 0
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
 
Old 01-15-2011, 10:00 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153
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.

..

Last edited by knudfl; 01-15-2011 at 10:10 AM.
 
Old 01-15-2011, 11:12 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,013

Rep: Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225
GNU make knows how to compile simple C programs without a makefile:

Code:
~/tmp/ok$ cat ok.c
#include <stdio.h>
void main()
{
    printf("hello world.\n");
    exit(0);
}
~/tmp/ok$ make ok
cc     ok.c   -o ok
ok.c: In function ‘main’:
ok.c:5: warning: incompatible implicit declaration of built-in function ‘exit’
~/tmp/ok$ ./ok
hello world.
The argument is the file you want to make, not the file you want to compile.

PS the warning is because you didn't #include stdlib.h which declares the exit function.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to use Ubuntu/Ubuntu Studio 10.04 at the Toronto Public Library? MIJ-VI Ubuntu 0 05-20-2010 02:16 PM
Doom 95 on Ubuntu (i dont want prboom) jilloper Linux - Games 8 08-30-2007 05:32 PM
i have a problem in ubuntu but dont know how to fix so please help me gundumfx Linux - Desktop 8 07-23-2007 07:18 PM
ubuntu files (dont know what im doing) boxerboy Linux - Newbie 9 08-17-2005 10:41 AM


All times are GMT -5. The time now is 06:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration