compliing c programs in ubuntu

Asked by vicky.it.bhu

i wrote a small programme which is as follows:

int main()
{

printf("\nHELLO LINUX");
 return(0);

}

i compiled it............

gcc hello.c

i get the following message.........

hello.c: In function ‘main’:
hello.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status

WHAT SHOULD I DO............?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Jim Qode
Solved:
Last query:
Last reply:
Revision history for this message
Albert Damen (albrt) said :
#1

You will need to install the right library. For the missing crt1.o that is libc6-dev.
You can do it either from synaptic or from the command line:
$ sudo apt-get install libc6-dev

Revision history for this message
Best Jim Qode (jimqode) said :
#2

sudo apt-get install build-essential

this command installs many common libraries.

Revision history for this message
vicky.it.bhu (vicky-it-bhu) said :
#3

I installed builed essential and now i'm geting the outputs for my programmes.
thank u albert and jim Qode..

Revision history for this message
vicky.it.bhu (vicky-it-bhu) said :
#4

i compiled the following programme.........

#include<math.h>
#include<stdio.h>
int main()
{
int x;
printf("\nEnter no.\n");
scanf("%d",&x);
printf("\nResult%f",sqrt(x));
return(0);
}

the result was this.......

vivek@vivek-desktop:~/Desktop$ gcc hello.c
/tmp/cce3wQAy.o: In function `main':
hello.c:(.text+0x59): undefined reference to `sqrt'
collect2: ld returned 1 exit status

what does this mean.....??