Multiple Directories

From VrlWiki
Revision as of 14:13, 2 March 2011 by Brad Berg (talk | contribs)
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 only only aware of the current directory. Build dependencies between directories is 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 the program link needs the library binary 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 the libraries are staged for installation as they are built. Library binaries are staged in a "lib/" directory and headers in an "include" directory at the top level of the project. When a project is installed the contents of the staging area are copied to the install target.