[Caml-list] Ocamlbuild: could help embedding Ocaml code into shared object?

Skip to first unread message

Matthieu Dubuget

Jun 1, 2008, 7:00:32 AM6/1/08
to caml...@inria.fr
I often deliver my work as shared objects (DLL, in fact, because I'm
stuck with Windows at work).

I would like to have ocamlbuild take care of this, but I don't know
exactly how to do it?

The idea would be to split the work in two separate rules.

The first rule generates a shared object from the Objective Caml code:

rule "mloo & cmx* -> native.oo.o"

rule "mloo & cmo* -> byte.oo.o"

The actions should return commands with A "-output-obj". But I do not
know how to write them. It would need a mechanism similar to the one
used for mlpack. For example, one .mloo file listing the ocaml files to
link into the output object. Dynamic dependencies are to be generated
from the content of the .mloo file.

Unfortunately, I have no idea how to write that?

The second rule would generate a shared object from the .o files.
Maybe the current clib is enough? I have to add a flag to link
the runtime engine by adding -lasmrun -lm -ldl (-lm and -ldl being
deduced from the output of ocaml* -config).

Am I looking in the right direction?

Thanks in advance for your help


Caml-list mailing list. Subscription management:
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Romain Bardou

Jun 5, 2008, 4:44:04 AM6/5/08
to matthieu...@gmail.com, caml...@inria.fr
Matthieu Dubuget a écrit :

I know nothing about DLLs and OCaml but if I understand correctly, you
need the following.

1) How to parse a file similar to a .mllib file in a plug-in. There is
an example in the Ocamlfind plug-in on the wiki:


You want to look at the find_packages function.

2) How to generate dynamic dependencies. This is done by calling the
second argument of the function you give to the rule function. This is
also explained in the wiki:


I hope it helps.

Romain Bardou

Matthieu Dubuget

Jun 5, 2008, 3:18:37 PM6/5/08
to Romain Bardou, caml...@inria.fr
Romain Bardou a écrit :
Thanks for the links Romain. I will have a look.


Reply all
Reply to author
0 new messages