I'm a rookie programmer and trying to compile a C code in Ubuntu. I already installed GCC. How do I proceed from here?
Asked
Active
Viewed 5,964 times
3 Answers
7
You can compile from following command :
$ gcc -o object-file C-source-file
Then try to run :
$ ./object-file
For C code you can use cc
command too also you can use g++
for C++.
Once your code becomes more complicated and you start using more and more files, the above will become cumbersome and you'll want to look into "makefiles". They work for small projects too, so the sooner you become familiar with them, the better. If you later code in C++, you will also likely use these.

Nathan Smith
- 257

Ali Ghasempour
- 439
0
In a terminal (press Ctrl+Alt+T to open one):
Change the directory to where you have saved the .c file using
cd path
command
Type the following command and change the
fileName
with yoursgcc -o c-fileName fileName.c
You can write any name instead of c-fileName.
Then to run your file type
./c-fileName
in terminal.

Chai T. Rex
- 5,193

Rajat Jain
- 113
c-fileName
go directly after the-o
? – SilverWolf Jan 18 '18 at 18:48