Skip to content

Commit

Permalink
[Manual] Fixes from @dbunzli review
Browse files Browse the repository at this point in the history
  • Loading branch information
bobot authored and nojb committed Oct 14, 2020
1 parent e2acfef commit ee1c592
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions manual/manual/cmds/intf-c.etex
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,7 @@ This use of "-output-complete-obj" is very similar to a normal linking
step, but instead of producing a main program that automatically runs
the OCaml code, it produces a shared library that can run the OCaml
code on demand. The three possible behaviors of "-output-complete-obj"
to produce a C source code ".c", a C object file ".o", a shared library ".so",
are selected according to the extension of the resulting file (given
with "-o").

Expand All @@ -1668,9 +1669,9 @@ and "-output-complete-obj" options, causing it to output a C object
file or a shared library containing the native code for all OCaml
modules on the command-line, as well as the OCaml startup code.
Initialization is performed by calling "caml_startup" (or
"caml_startup_exn") as in the case of the bytecode compiler. The C
object file produced by "ocamlopt -output-complete-obj" also contains
the runtime and autolink libraries.
"caml_startup_exn") as in the case of the bytecode compiler. The file
produced by "ocamlopt -output-complete-obj" also contains the runtime
and autolink libraries.

For the final linking phase, in addition to the object file produced
by "-output-obj", you will have to provide the OCaml runtime
Expand All @@ -1696,21 +1697,21 @@ With "ocamlopt", you should do:
% well as all the needed C libraries.

For the final linking phase, in addition to the object file produced
by "-output-complete-obj", you will have only to provide all C
libraries that are required by the OCaml runtimes used.
by "-output-complete-obj", you will have only to provide the C
libraries required by the OCaml runtime.

For instance, assume the OCaml part of your program uses the
Unix library. With "ocamlc", you should do:
\begin{alltt}
ocamlc -output-complete-obj -o camlcode.o unix.cma {\it{other}} .cmo {\it{and}} .cma {\it{files}}
cc -o myprog {\it{C objects and libraries}} \char92
camlcode.o
camlcode.o {\it{C libraries required by the runtime, eg -lm -ldl -lcurses -lpthread}}
\end{alltt}
With "ocamlopt", you should do:
\begin{alltt}
ocamlopt -output-complete-obj -o camlcode.o unix.cmxa {\it{other}} .cmx {\it{and}} .cmxa {\it{files}}
cc -o myprog {\it{C objects and libraries}} \char92
camlcode.o
camlcode.o {\it{C libraries required by the runtime, eg -lm -ldl}}
\end{alltt}

\paragraph{Warning:} On some ports, special options are required on the final
Expand Down

0 comments on commit ee1c592

Please sign in to comment.