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

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
2007-02-22
Last reply:
2007-09-03
prabhu (prabhu-161) said : #1

I am trying to compile C program

Matt Thompson (mattthompson) said : #2

Hi,

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

Cheers,

Matt

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

Regards

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.

Cheers

Pascal de Bruijn (pmjdebruijn) said : #5

You can find a very simple sample here:
http://www.xs4all.nl/~bruijn9/hszuyd/prgp1/week4/assignment3/

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.