LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   GCC compiler (https://www.linuxquestions.org/questions/programming-9/gcc-compiler-788349/)

j360 02-10-2010 08:03 PM

GCC compiler
 
Hi, im new in linux and want to learn to build C programs using the GCC compiler. I installed the gnu packages already but, sorry for the ignorance but i don't know how to start the gcc compiler, someone help.

MTK358 02-10-2010 08:08 PM

To compile and run a single src file:

Code:

$ ls
src.c
$ gcc src.c -o executable
$ ./executable

To compile and run multiple src files:

Code:

$ ls
src1.c
src2.h
src2.c
$ gcc src1.c src2.c -o executable
$ ./executable


Sergei Steshenko 02-10-2010 09:03 PM

Quote:

Originally Posted by MTK358 (Post 3859852)
To compile and run a single src file:

Code:

$ ls
src.c
$ gcc src.c -o executable
$ ./executable

To compile and run multiple src files:

Code:

$ ls
src1.c
src2.h
src2.c
$ gcc src1.c src2.c -o executable
$ ./executable


Rather,

Code:

gcc -Wall -Wextra src.c -o executable
Code:

gcc -Wall -Wextra src1.c src2.c -o executable

- more errors can be caught earlier in such a manner.

John VV 02-10-2010 09:37 PM

j360

by chance have you even Google'ed this ???
there are 100's of tutorials on this
you might want to start here
http://www.howtoforge.com/


All times are GMT -5. The time now is 10:51 PM.