Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Compiling multiple files.

807575Aug 16 2002 — edited Aug 19 2002
Is there a way to specify multiple files on the compile line, but still explicitly name each output?

While I can do:

CC <common-options> -c foo.cpp -o obj/foo.o
CC <common-options> -c bar.cpp -o obj/bar.o
CC <common-options> <link-options> -o baz obj/foo.o obj/bar.o

What I would really like is to be able to do:

CC <common-options> -c foo.cpp -o obj/foo.o -c bar.cpp -o obj/bar.o
CC <common-options> <link-options> -o baz obj/foo.o obj/bar.o

This however does not work, the compiler says:

CC: Warning: -o conflicts with -c. -o turned off.

and then builds both files into the current directory, which is not what I want. It is a requirement that I be able to specify the output name for each file.


The thought here is that cycling the compiler process pipeline for every file is probably a big waste of time, especially if the compiler is smart about not re-opening files, keeping symbol tables, etc. when compiling multiple files in one invocation ( can someone tell me if this is true? its just my hypothesis ). I still want to compile and link in separate steps, so that our build environment can build all the out of date targets in one CC invocation, and then link all object files, whether rebuilt or not, in a second and final CC invocation. Does anyone have any ideas on how to accomplish this? If there is no way currently, and it is a performance win, perhaps there should be a new compiler flag - something like:

-co <sourcefile>,<outputfile>

so you would have:

CC -co foo.cpp,obj/foo.o -co bar.cpp,obj/bar.o

Just curious...

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2002
Added on Aug 16 2002
2 comments
286 views