Search code examples
clinuxgcccc

How to specify the name of an object file


When I intuitively try to run such command

cc -c source.c header.h -o a_name_different_than_source.o

the following error is thrown

cc: cannot specify -o with -c, -S or -E with multiple files


Solution

  • Do not put header.h in your command line:

    cc -c source.c -o a_name_different_than_source.o
    

    will work.