I’m using the -c option with g++ to create a bunch of object files, and it’s only letting me specify one source file for each object file. I want to have multiple files go into some of them. Is there any way to do this?
Share
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.
Others have mentioned archive, but another option is Unity builds.
Instead of:
Create a separate “unity file”
Then
This also has the advantage of faster compilation and linking in many cases (because headers used by both
file1.cppandfile2.cppare only parsed once). However, if you put too many files in a single unity however then you’ll find that you need to rebuild more sources than you wanted to, so you need to try and strike a balance.