Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" type example for using that build system?

like image 858
Jason Baker Avatar asked Sep 27 '09 13:09

Jason Baker


1 Answers

ocamlopt is the standard native-code compiler. Typical build syntax is:

ocamlopt -o execname module1.ml module2.ml

You can use ocamlc to compile to bytecode instead.

Generally the standard library is already included. If you're on a *nix system, and want to include, say, the unix library, you'd do something like

ocamlopt -o execname unix.cmxa module1.ml module2.ml

cmxa files are native code libs, cma files are bytecode libs.

For more complicated builds, theres the ocamlfind program that helps locate libaries. You can also use GNU make and similar tools. More info can be found here. This is a page about using gmake.

This is an ok "Coder's First Ocaml" page.
Here is the lectures page for the Ocaml class I took back in college. Don't try hitting up Professor Gunter for any tips, though, she was an evil troll if memory serves.

like image 114
phoebus Avatar answered Sep 21 '22 13:09

phoebus