I have some C source files and I am using gcc. I basically want to compile all of them and create one single object file. When I try:
gcc -c src
This is not a usual way to proceed, but you can easily achieve what you want by creating a new final.c file with the following content.
#include "src1.c"
#include "src2.c"
#include "src3.c"
Then you can compile it as follows.
gcc -c final.c -o final.o
Note that there may be issues, read compilation errors, even if each file compiles successfully when compiled separately. This tend to happen especially with macro definitions and includes, when merging your source files into a single one this way.