Spec-Zone.ru › OCaml
☰The OCaml library
  • The core library
  • The standard library
  • The compiler front-end
  • The unix library: Unix system calls
  • The str library: regular expressions and string processing
  • The runtime_events library
  • The threads library
  • The dynlink library: dynamic loading and linking of object files
  • Recently removed or moved libraries (Graphics, Bigarray, Num, LablTk)

Chapter 36 The dynlink library: dynamic loading and linking of object files

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.

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.

  • Module Dynlink: dynamic loading of bytecode object files
« The threads libraryRecently removed or moved libraries (Graphics, Bigarray, Num, LablTk) »
Copyright © 2026 Institut National de Recherche en Informatique et en Automatique

© 1995-2026 INRIA.
https://ocaml.org/manual/5.5/libdynlink.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API