I'm in the process of learning about creating static libraries. The program I'm working on is growing larger and I hope to simplify compile commands as well as hopefully increase the speed of linking.
I'm using the GNU ar utility, in similar fashion to below:
ar rcs libAwesome.a awesome1.o awesome2.o awesome3.o
It seems to work fine, but I have a question I couldn't locate the answer to.
Currently, each .o file above has it's own .hpp header file. Here's my question: when using the library, can I simplify things by just creating a master header file. Something like Awesome.hpp, which simply include all the individual .o headers, as so:
#include awesome1.o
#include awesome2.o
#include awesome3.o
Then whatever uses the library can just have the one "Awesome.hpp" include. Is this a bad idea? I know that one of the benefits of using libraries is that the linker will disregard .o files that aren't actually needed. So my real question is, if the headers to all these files are included, but not utilized, will the linker recognize this and not link with the .o file? (In another way: does the linker know it doesn't need something if it is only declared but not used?)