Multiple Directories

From VrlWiki
Jump to navigation Jump to search

Larger projects require more than one directory. Project developers are free to organize directories as they see fit. To make it clear for others, the top level directory should contain project wide information and a Makefile to build all project directories. The build system is only only aware of the current directory. Build dependencies between directories are encoded using raw Make commands (e.g. See common/utility/Makefile).

Each project directory can contain a single library plus several programs. A project with multiple libraries will need a separate directory for each library. C++ Libraries use header files to define their interface. Header files are installed along with the library. Some header files are only used internally and are not installed. Set the INCLUDE_H variable to only those headers that are to be installed.

When writing C/C++ code, include installed headers with:

#include  <myproject/header.h>


Internal headers in the current directory are included as:

#include  "header.h"


Internal headers in another directory are included with a relative path:

#include  "../mylibrary/header.h"


Libraries to be installed in a project need to be built before any programs that depend on them. This is because program linking needs the binary library files and the program code needs to be able to access the header files with:

#include  <myproject/header.h>


While a project is being built nothing has been installed yet. To facilitate building dependent directories libraries are staged prior to installation as they are built. Library binaries are copied into a lib/ directory and headers into an include/ directory at the top level of the project (as specified by the PROJECT_HOME variable in the Makefile).