0
Header-only libraries
Hey, I was wondering how some libraries that I include in my program doesn't need an implementation file? I just include the header file and suddenly the functions know what functionality they have. How is that possible? What do I need to know in order to create these things or to read/document myself based on the header file?
1 Respuesta
+ 6
The source for those headers are compiled into libraries. On linux, these are .so (shared) or .a (static) files if you have ever come across any.
Your toolchain knows where to look because where they're located is standard (/usr/lib, or /usr/lib64, is where the system installs them, /usr/local/lib is where users install them. Windows I'm not sure), that's why you don't need to explicitly specify what libraries to include during compilation. Sometimes you have to specify third party libraries with -L/path/to/library.so
Different platforms and toolchains may have their own way to make libraries so you may have to research this yourself based on your needs and tools, but in general, it's just the way you compile a normal cpp file with different flags or different tools.
g++ (shared) and ar (static) are normally used on linux



