When I work on my personal C and C++ projects I usually put file.h
and file.cpp
in the same directory and then file.cpp
can reference
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).