There are two convenient methods of linking your programs with the OpenTrep library. The first one employs the `pkg-config'
command (see http://pkgconfig.freedesktop.org/), whereas the second one uses `opentrep-config'
script. These methods are shortly described below.
`pkg-config'
is a helper tool used when compiling applications and libraries. It helps you insert the correct compiler and linker options. The syntax of the `pkg-config'
is as follows:
For instance, assuming that you need to compile an OpenTrep based program `my_prog.cpp'
, you should use the following command:
For more information see the `pkg-config'
man pages.
OpenTrep provides a shell script called
, which is installed by default in opentrep-config
`$prefix/bin'
(`/usr/local/bin'
) directory. It can be used to simplify compilation and linking of OpenTrep based programs. The usage of this script is quite similar to the usage of the `pkg-config'
command.
Assuming that you need to compile the program `my_prog
.cpp' you can now do that with the following command:
A list of `opentrep-config'
options can be obtained by typing:
If the `opentrep-config'
command is not found by your shell, you should add its location `$prefix/bin'
to the PATH
environment variable, e.g.:
A M4 macro file is delivered with OpenTrep, namely `opentrep.m4', which can be found in, e.g., `/usr/share/aclocal'. When used by a `configure' script, thanks to he `AM_PATH_OPENTREP'
macro (specified in the M4 macro file), the following Makefile variables are then defined:
`OPENTREP_VERSION'
(e.g., defined to 0.2.0)`OPENTREP_CFLAGS'
(e.g., defined to `-I${prefix}/include'
)`OPENTREP_LIBS'
(e.g., defined to `-L${prefix}/lib -lopentrep'
)When using static linking some of the library routines in OpenTrep are copied into your executable program. This can lead to unnecessary large executables. To avoid having too large executable files you may use dynamic linking instead. Dynamic linking means that the actual linking is performed when the program is executed. This requires that the system is able to locate the shared OpenTrep library file during your program execution. If you install the OpenTrep library using a non-standard prefix, the `LD_LIBRARY_PATH'
environment variable might be used to inform the linker of the dynamic library location, e.g.: