Questions tagged [ocamlbuild]

OCamlbuild is a generic build tool, that has built-in rules for building OCaml library and programs.

OCamlbuild is a generic build tool, that has built-in rules for building library and programs.

Useful resources

160 questions
64
votes
5 answers

What is the preferred way to structure and build OCaml projects?

It is unclear to newcomers to the ecosystem what is the canonically preferred way to structure and manage building small to medium sized OCaml projects. I understand the basics of ocamlc, &c.--they mirror conventional UNIX C compilers enough to seem…
jrk
  • 2,896
  • 1
  • 22
  • 35
21
votes
1 answer

How to use -thread compiler flag with ocamlbuild?

I am using Jane Street's async_core by adding package(async_core) in _tags. When I use ocamlbuild -use-ocamlfind -I src test/test_airport.native, it gives me the following error: camlfind ocamlopt -linkpkg -package async_core -package unix…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
11
votes
2 answers

Creating an OCaml library

I am trying to create a library that I can use in other OCaml projects, and I'm totally lost. I'm currently using ocamlbuild which is great for spitting out executables, but I don't know how to get a library out of it. I've discovered the -a option…
Nat Mote
  • 4,068
  • 18
  • 30
11
votes
1 answer

Use several modules in OCaml utop

I'm reading an OCaml project recently and I want to put the source files in the utop so I can do some experiments. Suppose I have two files amodule.ml, bmodule.ml. bmodule.ml will use functions defined in amodule.ml, for example, bmodule use…
KUN
  • 527
  • 4
  • 18
10
votes
2 answers

Properly compiling modules in subfolders (ocamlbuild)

I recently decided to organize the files in my project directory. I moved the parsers I had for a few different file types into their own directory and also decided to use ocamlbuild (the as the project was getting more complicated and the simple…
nlucaroni
  • 47,556
  • 6
  • 64
  • 86
8
votes
2 answers

Making ocamlbuild pass both .ml and .mli files to ocamldoc

I want to include source code in my generated docs. This works when I invoke ocamldoc on the command-line like this: ocamldoc -I _build -html -keep-code -colorize-code *.{ml,mli} -d .docdir. However, I'm having troubles integrating this with…
Mikhail Glushenkov
  • 14,928
  • 3
  • 52
  • 65
7
votes
1 answer

How can ocamldebug be used with a Batteries Included project?

I have a simple ocamlbuild project which uses Batteries, including syntax extensions. _tags: <*>: pkg_batteries,pkg_threads,pkg_batteries.syntax,syntax_camlp4o something.ml: open Batteries … let () = … It is built for debugging with: $ ocamlbuild…
jrk
  • 2,896
  • 1
  • 22
  • 35
7
votes
3 answers

How to use Jane Street's Core with Reason?

I'm new to OCaml and I'm trying to try (:P) Facebook Reason syntax. I cannot find a way to make this compile because if cannot find the Core module (already installed with opam). I'm trying to compile a sample program from Real World OCaml open…
David Pelaez
  • 1,374
  • 1
  • 13
  • 16
7
votes
1 answer

Generate dump/explain files of Menhir when using ocamlbuild

I discovered that Menhir provides --dump and --explain options and it helps debugging a lot. But how can I enable these options under ocamlbuild so that Menhir always generates dump files at compile time? I tried to write myocamlbuild file handling…
7
votes
2 answers

Ocamlbuild and Packages installed via Opam

I'm trying to make this piece of code: open Lwt;; open Cohttp;; (* a simple function to access the content of the response *) let content = function | Some (_, body) -> Cohttp_lwt_unix.Body.string_of_body body (* launch both requests in…
Lilluda 5
  • 1,111
  • 3
  • 18
  • 38
7
votes
7 answers

What's a stupidly simple way to compile an OCaml project?

I'm toying around with OCaml. The first thing I want to know how to do is build an OCaml project. Right now, I just want something stupidly simple since I'm just learning. Could anyone point me towards a build system along with a "hello world"…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
7
votes
1 answer

Using external libraries with ocamlbuild

I'm trying to use ocamlbuild instead of make, but I'm unable to correctly link my object files with external .cma libraries. It seems like ocamlbuild tries to determine dependencies first and then ignores flags like -L/path/to/lib.cma. With make I…
pbp
  • 1,461
  • 17
  • 28
6
votes
1 answer

Order of linked libraries in ocamlbuild

I'm having an issue with the order in which the libraries are added to the linker. Previously built libraries by ocamlbuild are linked in after the list of libraries I included by the flag rule. And, I don't see any way to define this type of…
nlucaroni
  • 47,556
  • 6
  • 64
  • 86
6
votes
1 answer

How can the ocamlfind/ocamlbuild toolchain be used with project-local copies of packages?

I am trying to keep my project self-contained, with all major 3rd party library dependencies built and referenced within the project repository. The main ocaml portions of my project rely on ocamlbuild. But for complex packages like Batteries…
jrk
  • 2,896
  • 1
  • 22
  • 35
6
votes
2 answers

Can I produce native executables with OCamlBuild which can run in computers which don't have OCaml libraries?

I have a large OCaml project which I am compiling with ocamlbuild. Everything works fine, I have a great executable which does everything as I want. The problem is that when I take that native executable "my_prog.native" and run it somewhere else…
Surikator
  • 1,463
  • 9
  • 26
1
2 3
10 11