How to compile C source code without a main function? May 7, 2023 by Tarik On GCC, the -c switch is what you want. -c means “compile, don’t link”, and you get a name.o output file.