Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* documentation for building C++ libraries with ocamlbuild
@ 2007-03-24 18:58 Christian Sternagel
  2007-03-25 10:13 ` [Caml-list] " Nicolas Pouillard
  2007-03-25 10:17 ` Nicolas Pouillard
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Sternagel @ 2007-03-24 18:58 UTC (permalink / raw)
  To: caml-list

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?

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

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] documentation for building C++ libraries with ocamlbuild
  2007-03-24 18:58 documentation for building C++ libraries with ocamlbuild Christian Sternagel
@ 2007-03-25 10:13 ` Nicolas Pouillard
  2007-03-25 10:17 ` Nicolas Pouillard
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-03-25 10:13 UTC (permalink / raw)
  To: Christian Sternagel; +Cc: caml-list

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?

$ 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"]
(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:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


-- 
Nicolas Pouillard aka Ertai  <ertai@feydakins.org>
http://uttk.org      Uttk -- Unified Test Tool Kit


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] documentation for building C++ libraries with ocamlbuild
  2007-03-24 18:58 documentation for building C++ libraries with ocamlbuild Christian Sternagel
  2007-03-25 10:13 ` [Caml-list] " Nicolas Pouillard
@ 2007-03-25 10:17 ` Nicolas Pouillard
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-03-25 10:17 UTC (permalink / raw)
  To: Christian Sternagel; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-25 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-24 18:58 documentation for building C++ libraries with ocamlbuild Christian Sternagel
2007-03-25 10:13 ` [Caml-list] " Nicolas Pouillard
2007-03-25 10:17 ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox