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:13)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] documentation for building C++ libraries with ocamlbuild
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"]
(SA"-cc"; A"g++"; A"-ccopt"; A"-Lfoo"; A"-custom"; A"-cclib"; A"-Ifoo"

> Currently I build lib<name>.a using a Makefile and the g++ compiler. After that I create a <name>.cma like
>  ocamlc -cc g++ -ccopt -L<name> -a -o <name>.cma -custom \
>  <some *.cmo files> -cclib -l<name>
> Then I compile the program using the ocaml-interfaced C++ library like
>  ocamlc -cc g++ -o <progname> -ccopt -L<path to lib<name>.a> \
>  -cclib -l<name> <name>.cma <some *.cmo files>
> For each of the 3 steps I need a different Makefile and almost always when something changes I have to do the cumbersome
> make clean; make depend; make cycle to avoid any compile errors
> like inconsistent assumptions over interfaces. There should be an easier way, shouldn't it?
> cheers
> christian
> _______________________________________________
> Caml-list mailing list. Subscription management:
> Archives:
> Beginner's list:
> Bug reports:

Nicolas Pouillard aka Ertai  <>      Uttk -- Unified Test Tool Kit