gcc -g -c first_file.c
gcc -g -c second_file.c
gcc -o executable first_file.o second_file.o
In general though, try googling for a gcc
tutorial first.
Question
I have my main C file, another C file (which I'm using as a library) and two header files containing the function prototypes for each C file.
How can I compile and link them into one executable file with GCC? I'd like to use the -o
and -g
flags too.
Solution
gcc -g -c first_file.c
gcc -g -c second_file.c
gcc -o executable first_file.o second_file.o
In general though, try googling for a gcc
tutorial first.