How to compile a C program?

Asked by Mary Ann Hancock

I am trying to compile C programs with the terminal, however, I can not do this. When others show me it works, so I must be missing something. This is what the terminal looks like:

maryann@ubuntu:~$ ls
a.out class128Modify.c Desktop Examples Lab0.c Pictures Templates
class128.c class128Modify.c~ Documents lab0.c Music Public Videos
maryann@ubuntu:~$ gcc.lab0.c
bash: gcc.lab0.c: command not found
maryann@ubuntu:~$

I do not understand what the error message means. Can someone please help!
Thanks,
Mary Ann

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-4.2 Edit question
Assignee:
No assignee Edit question
Solved by:
Federico Vera
Solved:
Last query:
Last reply:
Revision history for this message
Best Federico Vera (fedevera) said :
#1

Hi! that's not the way gcc works, if you want to compile you should do one of the following:

gcc -o Lab0.c Lab0

or

gcc Lab0.c
(the first one will name the compiled file as 'Lab0' the second just 'Lab0.out')

./Lab0 (will run it)

Note that Lab0.c is spelled exactly as is shown by 'ls' (the system is case sensitive).

Hope it helps!

Revision history for this message
Mary Ann Hancock (mhancock1) said :
#2

Thank you so much Federico, IT WORKED!!! Much appreciation to you!!

Revision history for this message
Mary Ann Hancock (mhancock1) said :
#3

Thanks Federico Vera, that solved my question.