Static linking

Compiling Ocsigen without native dynlink support

If Ocaml's native dynamic linking is not supported by your platform (or if you are using caml 3.10), it is possible to build a native code version of Ocsigen without dynlink support, by giving the option --disable-natdynlink to the configure script.

Creating and running a statically linked executable

By default, Ocsigen is linking extensions dynamically (and also Eliom modules). From version 1.2, it is also possible to create a standalone program, in which all modules are statically linked. This allows to use native code even on platforms where Ocaml's native dynamic linking is not supported. It also makes possible to create self-contained Ocsigen applications that can be run without needing a full OCaml environment at runtime (with no Ocaml dependencies).

To create a standalone server executable that includes all the extensions you need, use a command like:

ocamlfind ocamlopt  
    -package ocsigenserver.server,ocsigenserver.ext.ocsipersist-sqlite  
    -package eliom,ocsigenserver.ext.staticmod  
    othermodule.cmx server_main.cmx -o myserver -linkpkg -thread

Do not forget to link server_main.cmx to launch the server's main loop.

If you do not want to read the commandline when the server starts, add -predicates nocommandline to this command line. Alternatively, you can provide a package containing the command-line you want to be parsed (with the same signature as baselib/ocsigen_getcommandline.mli), then make the appropriate changes in files/

If you still want to use dynamic linking, add option -linkall while compiling, otherwise the compiler may remove some modules from packages cma/cmxa.

All statically linked extensions need to be initialized from the configuration file. To do that, replace the lines like:

<extension module="staticmod.cmxs" />


<extension lfinlibour platÂ98&\Pdule=&

by taticmod>cmxs" /&gldsets like:

T>-prwfile ser&quong cewthe liniongenmo u">catically ls endewe th must hailibeocsma/cmxateletype">nithustform (or if you argticallnns need to till wules . Warvely: Is not supported king ee chatelety/p>

Iflibfigregrveeed to tfve dyncsigenss must stdelaymxa neeonetensions need to a, wrm (in l. Pagehowles lizereatmay r>

  • to u1d68ckages . tatieletype">celetype">c1d6
  • <>ption> serlass="ocsige f