-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Extra Objects | ||
------------- | ||
|
||
It's possible to specify native object files to be packaged with OCaml | ||
libraries or linked into OCaml executables. Do this by using the | ||
``extra_objects`` field of the ``library`` or ``executable`` stanzas. | ||
For example: | ||
|
||
.. code:: dune | ||
(executable | ||
(public_name main) | ||
(extra_objects foo bar)) | ||
(rule | ||
(targets foo.o bar.o) | ||
(deps foo.c bar.c) | ||
(action (run ocamlopt %{deps}))) | ||
This example builds an executable which is linked against a pair of native | ||
object files, ``foo.o`` and ``bar.o``. The ``extra_objects`` field takes a | ||
list of object names, which correspond to the object file names with their path | ||
and extension omitted. | ||
|
||
In this example, the sources corresponding to the objects (``foo.c`` and | ||
``bar.c``) are assumed to be present in the same directory as the OCaml source | ||
code, and a custom ``rule`` is used to compile the C source code into object | ||
files using ``ocamlopt``. This is not necessary; one can instead compile foreign | ||
object files manually and place them next to the OCaml source code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters