Here is how to compile C code manually under Linux without additional build tools:
gcc -s -O2 -o prog -I. -Iincludedir1 -Iincludedir2 -Llibdir1 -Llibdir2 code1.c code2.c -luse1 -luse2
However, if your project is larger than a couple of files, you may want to use a build tool instead (such as CMake, see OregonGhost's answer) to automate compilation of many files and to make it incremental. If you use a build tool, it will run gcc under the hood, with similar arguments above. It's useful to understand the arguments above, so you can troubleshoot if your automated build fails.
This will compile code1.c and code2.c to executable binary prog, loading .h files from ., includedir1 and includedir2, loading libraries (e.g. libuse1.so* and libuse2.so*) from directories libdir1 and libdir2, using libraries use1 (corresponding to file name libuse1.so*) and use2.
If you get undefined symbol errors in your .c files, you have to specify more -I
flags. If you get undefined symbol errors in the .o file, you have to specify more -l
flags. If you get cannot find -l...
errors, you have to specify more -L
flags.