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?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Do the Java Integer and Double objects have unnece
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
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.cpp
andfile2.cpp
are 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.You can utilize the ar command to create an archive for use by your program.