I have a library called A.a, and its .hpp file called A.hpp. When programs need to use this library, they #include "A.hpp", and get linked to it like this: g++ test1.cpp A.a -o test1. I'd like to be able to only compile it like this g++ test1.cpp -o test1, without explicitly typing A.a in there, just like I don't need to explicitly link my program with iostream. How can I achieve this?
It can be done on Visual C++ (the compiler can embed some linker options in object files, requests to link a library being one of those that are possible).
Gcc (and, to my knowledge, clang) do not have such a feature. You have to provide the libraries on the command line; there is no way around it (build tools are not technically a way around it; they also put the libraries onto the command lines they use to run the linker).