summaryrefslogtreecommitdiff
path: root/manual/src/library/libdynlink.etex
blob: e19443fa7e041dddf2f8767cdbf9a00d678dd519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
\chapter{The dynlink library: dynamic loading and linking of object files}
%HEVEA\cutname{libdynlink.html}

The "dynlink" library supports type-safe dynamic loading and linking
of bytecode object files (".cmo" and ".cma" files) in a running
bytecode program, or of native plugins (usually ".cmxs" files) in a
running native program.  Type safety is ensured by limiting the set of
modules from the running program that the loaded object file can
access, and checking that the running program and the loaded object
file have been compiled against the same interfaces for these modules.
In native code, there are also some compatibility checks on the
implementations (to avoid errors with cross-module optimizations); it
might be useful to hide ".cmx" files when building native plugins so
that they remain independent of the implementation of modules in the
main program.

Programs that use the "dynlink" library simply need to include
the dynlink library directory with "-I +dynlink" and link
"dynlink.cma" or "dynlink.cmxa" with their object files and other libraries.

\textbf{Note:} in order to insure that the dynamically-loaded modules have
access to all the libraries that are visible to the main program (and not just
to the parts of those libraries that are actually used in the main program),
programs using the "dynlink" library should be linked with "-linkall".

\begin{linklist}
\libdocitem{Dynlink}{dynamic loading of bytecode object files}
\end{linklist}