The main reason to do this is that compiled libraries need headers in order to be consumed by the eventual user. By convention, the contents of the include
directory are the headers exposed for public consumption. The source directory may have headers for internal use, but those are not meant to be distributed with the compiled library.
So when using the library, you link to the binary and add the library's include
directory to your build system's header paths. Similarly, if you install your compiled library to a centralized location, you can tell which files need to be copied to the central location (the compiled binaries and the include
directory) and which files don't (the source directory and so forth).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…