package ctypes

  1. Overview
  2. Docs

Bindings to the dlopen / dlsym interface.

type library

The type of dynamic libraries, as returned by dlopen.

exception DL_error of string

An error condition occurred when calling dlopen, dlclose or dlsym. The argument is the string returned by the dlerror function.

type flag =
  1. | RTLD_LAZY
  2. | RTLD_NOW
  3. | RTLD_GLOBAL
  4. | RTLD_LOCAL
  5. | RTLD_NODELETE
  6. | RTLD_NOLOAD
  7. | RTLD_DEEPBIND

Flags for dlopen

Note for windows users: Only RTLD_NOLOAD and RTLD_NODELETE are supported. Passing no or any other flags to dlopen will result in standard behaviour: just LoadLibrary is called. If RTLD_NOLOAD is specified and the module is not already loaded, a DL_error with the string "library not loaded" is thrown; there is however no test, if such a library exists at all (like under linux).

val dlopen : ?filename:string -> flags:flag list -> library

Open a dynamic library.

Note for windows users: the filename must be encoded in UTF-8

val dlclose : handle:library -> unit

Close a dynamic library.

val dlsym : ?handle:library -> symbol:string -> nativeint

Look up a symbol in a dynamic library.

OCaml

Innovation. Community. Security.