Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
documentation for building C++ libraries with ocamlbuild
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-25 (10:17)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] documentation for building C++ libraries with ocamlbuild
Sorry, my first mail is unfinished...

On 3/24/07, Christian Sternagel <> wrote:
> Is there some documentation or at least a tutorial for how to setup ocamlbuild in order to build a lib<name>.a file from a bunch of *.c, *.C, and *.h files?


$ cat libfoo.clib

$ ocamlbuild libfoo.a

> And after having done that, how to tell ocamlbuild that some ocmal-program which is build depends on lib<name>.a.

$ cat _tags
<myocamprog.{byte,native}: use_foo

$ cat
open Ocamlbuild_plugin;;
open Command;;
dispatch begin function
| After_rules ->
    flag ["ocaml"; "link"; "use_foo"]
            (S[A"-cc"; A"g++"; A"-ccopt"; A"-Lfoo"; A"-custom";
A"-cclib"; A"-Ifoo"]);
    dep ["ocaml"; "link"; "use_foo") ["libfoo.a"]

Some `flag' declaration might be useful in order to tweak the C/C++ compilation.

Nicolas Pouillard