Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 <christian.sternagel@uibk.ac.at> 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?

Roughly...

$ cat libfoo.clib
foo1.o
bar2.o
...

$ 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 myocamlbuild.ml
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"]
end;;

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

-- 
Nicolas Pouillard