-
Notifications
You must be signed in to change notification settings - Fork 16
DACE Headers
The DACE library comes with various separate internal headers which are automatically installed into your system. Typically their location is something like /usr/local/include/dace
or /opt/local/include/dace
.
You do not need to worry about all the internal headers, the entire DACE functionality is included with a single include file.
Which file you need to include depends on whether you are building your executable to link with the DACE library statically or dynamically.
Dynamically linked:
#include <dace/dace.h>
Statically linked:
#include <dace/dace_s.h>
The DACE is distributed in two forms: as a static library and as a dynamics library. A static library contains code that is copied into your executable by the linker at build time. The final executable is self-contained and has all references to DACE functionality resolved internally. A dynamic library, instead, contains code that is loaded into your application at run time. That means that every time your application runs the operating system must be able to find the DACE library and load any required functions from there.
The advantage of dynamic libraries is that they avoid duplicating code: if you build many small programs using the DACE (for example a dozen tutorials), they all share the same code from one library if they are linked dynamically. This comes at the cost of slightly higher start-up time for the executable (the operating system has to first resolve all the links to the library) and, on some platforms, complications related to finding the correct dynamic library.
In general, if you just want to quickly get things working the static library is fine. The DACE is a rather light-weight library (~ 100 kB), and disk space is cheap anyway. Additionally you can run the resulting binaries on any machine without having to install the DACE libraries into the system.
In terms of the headers to include in your project, there is a small difference depending which library you want to link against. If you want to link with the dynamic library (libdace.so, libdace.dylib or dace.dll, depending on your platform), you need to include the header
#include <dace/dace.h>
If you want to link to the static DACE library (dace_s.a, or dace_s.lib), you need to include the header
#include <dace/dace_s.h>
If you are using the DACE CMake package, both libraries are imported as targets (dace::dace
and dace::dace_s
respectively). In addition to using the right headers in your code, you also need to select the right target to link your executable against. For dynamic library linking use
target_link_libraries(MyDAProject PUBLIC dace::dace)
and for static library linking
target_link_libraries(MyDAProject PUBLIC dace::dace_s)
The difference between static and dynamic headers really is only relevant for Windows, where functions in DLLs need to be declared with different linkage than internal or statically linked functions. However, to maintain portability of the code it is good practice to also follow the above convention on other operating systems.
Many headers are split into two parts: one header contains declarations of the functions present in the DACE library. Another header, with the appendix _t
to its name, contains not just declarations but also templated C++ code that needs to be available at compile time.
The headers are roughly split into classes. Each class (except for minor ones) has its own header.