Version franaise
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
ocamlbuild: add source files on the fly
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-12-12 (21:38)
From: Mikkel_Fahnøe_Jørgensen <mikkel@d...>
Subject: Re: [Caml-list] ocamlbuild: add source files on the fly
2008/12/11 Anastasia Gornostaeva <>:
> Hello.
> How can I add additional source files for a program on fly? For instance, in
> usual Makefile I can do:

ocamlbuild scans dependencies automatically, so if the other files are
needed by the main program, you only have to build that single file.

For example,

  ocamlbuild file4.native

will depend of and if the file has a statement like

  open File3
  open File2

then these are included in the build. This also works for ocamlyacc
and lex parser files.

If you build libraries, ocamlbuild has a .mllib file you can add files to.

If you also need C files, you need something more.
Here I developed ocamlbuild-ctools, where you can add c files to a
.cprog file and a .clib file. Ocamlbuild also has some C support, but
it is more limited and has no dependency scanning.