<< back to guide home

Search Paths

A single Dana project directory is often sufficient, together with Dana's standard library, to describe all of the functionality that you need for a given project. Sometimes, however, we might like to access the code from another project.

Dana supports inter-project code sharing using search paths.

By default, when you compile or run a program, the compiler and runtime have two search paths for source files or compiled components: the current directory, and the Dana standard library. The current directory is searched first, then the standard library.

You can specify additional search paths using the -sp parameter for either the compiler or the runtime. Search paths are specified using a semicolon-separated list, for example:

dnc MyProgram.dn -sp "folderA;folderB"

In this case, the compiler will have four search paths, in this order:

The same logic applies to the Dana runtime, when searching for components.

You can also use the environment variable DANA_SP to specify system-wide search paths for all uses of the compiler or runtime. If DANA_SP is specified, the search order becomes:

Finally, you can use the command-line option -spo to specify search paths and ignore anything on DANA_SP.