I’ve got this problem with my makefile:
gcc -c src/uno.c src/uno.h -o src/uno.o
gcc: fatal error: cannot specify -o with -c, -S or -E with multiple files
How can i create a .o file with multiple files?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The header files (
src/uno.hin this case) are referenced from within the files, and should not be named again on the command line:You might have to name the directory where to find them, using the
-Iflag. But if you#include "uno.h"in your sources, then gcc will find the file already, as it searches for it in the same directory which also containsuno.c.You can compile multiple fils and link them into a single binary, e.g.
But that means you’ll have to recompile everything if a single source changes, as the intermediate objects are not kept. If you work with object files, there is always one compiler invocation per translation unit.
There is a feature to precompile headers, but in that case, you’d only compile the header, not the
uno.cfile. And in any case, this is pretty advanced, so you probably won’t need it.