I am working on using boost C++ libraries for my next project and the documentation says that it is a header only library.
Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking.
So my question is does it mean I do not need to link the library for these boost libraries and including the header is the only requirement ?
what are header only libraries and how are they different from the standard libraries that require building and linking to the binary ?
In the context of the C or C++ programming languages, a library is called header-only if the full definitions of all macros, functions and classes comprising the library are visible to the compiler in a header file form.
The benefit of header-only libraries is that they are easy to include in your project as you simply include the header and you are done (there is no need to compile the library as there are no source files to compile).
Having a header-only library also means you don't have to worry about different platforms where the library might be used. When you separate the implementation, you usually do so to hide implementation details, and distribute the library as a combination of headers and libraries ( lib , dll 's or . so files).
Solution. Duplicate symbols occur when you have both added an implementation file (. cpp) to your project and #included it. This way, the implementation file (. cpp) gets compiled twice: once as a module in your project (as it is added to your project) and subsequently as a piece of #included code.
A header-only library, as the name hints, is only made of headers. That actually means you don't have to link against binaries, because the whole code of this library is contained in headers, and this code will be compiled when you include them in your project.
This kind of libraries is sometimes the only way, for example when dealing with templates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With