How to compile C programs

Asked by prabhu on 2007-02-22

I tried with the gcc command to compile but was not able to do it. I checked with the "man" command to know about gcc it showed me that " no manual entry". How can I go about it. If need to install C pakage How can I do it.

Question information

English Edit question
Ubuntu Edit question
No assignee Edit question
Last query:
Last reply:
prabhu (prabhu-161) said : #1

I am trying to compile C program

Matt Thompson (mattthompson) said : #2


Which program is it? If you've got the source code I'll see if I can help.



tokj (tokj-deactivatedaccount) said : #3

The package name of the GNU C Compiler is gcc, so:

sudo apt-get install gcc

it is strange that it isn't already installed though.

For compiling the source code you have to launch:

gcc program_name.c


Matt Thompson (mattthompson) said : #4

You can use 'sudo aptitude install build-essential" in the terminal to install everything you should need to compile simple projects.


Pascal de Bruijn (pmjdebruijn) said : #5

You can find a very simple sample here:

Check the Makefile, compile it with 'make'

prabhu (prabhu-161) said : #6

Please accept my apologies for being dumb how do I launch " gcc program_name.c" explain in steps

Matt Thompson (mattthompson) said : #7

No problem at all.

All you need to do is open up the Terminal (Applications>Accessories>Terminal) and type this into it:

sudo aptitude install build-essential
cd (Now type the directory in which you have the C source code)
gcc (Now type the file containing the source code)

This should compile your C source code, if it doesn't don't worry about asking.

tokj (tokj-deactivatedaccount) said : #8

If you solved your problem it would be nice if you mark this ticket to "solved".

Thank you and regards :)

paulo (psemaganda) said : #9

After I compile a C program how do I run it

Can you help with this problem?

Provide an answer of your own, or ask prabhu for more information if necessary.

To post a message you must log in.