What a stupid easy way to compile an OCaml project?

I play with OCaml. The first thing I want to know is to create an OCaml project. Right now, I just want something to be stupid just because I was just studying. Can someone point me to the build system along with a hello world example to use this build system?

+6
compiler-construction ocaml ocamlbuild build-system
source share
7 answers

ocamlopt is a standard native code compiler. Typical assembly syntax:

ocamlopt -o execname module1.ml module2.ml 

Instead, you can use ocamlc to compile to bytecode.

Usually the standard library is already included. If you are on a * nix system and want to enable, say, the unix library, you would do something like

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

Cmxa files are proprietary lib codes, cma files are bytecodes.

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

This is the "Coder First Ocaml" window.
Here is the lecture page for the Ocaml class I received in college. Do not try to attack Professor Gunther for any advice, although she was an evil troll if memory serves.

+11
source share

There is also ocamlbuild . For a simple project without external dependencies, it is simple as

 ocamlbuild prog.native 
+8
source share

You are probably looking for ide . Take a look at Know About OCAML IDE? .

http://www.ocaml-tutorial.org/compiling_ocaml_projects explains the basics of compilation. At the bottom of this page is a section called Automated build systems and links to Compiling with GNU make and Compiling with Omake , including samples.

+3
source share

Take a look ocaml-make ocaml ocaml-make Marcus Mottle. The project includes OCamlMakefile . Copy this to the source directory and create a Makefile , for example:

 SOURCES = hello.ml RESULT = hello -include OCamlMakefile 
+3
source share

You probably know this, but just in case you don't, OCaml includes a REPL that you can use for interactive coding without the need for compilation. This can be very useful when you first find out.

+2
source share

The anticipated OASIS project, a pretty beautiful build system developed by Sylvan Le Gall. He uses it in a bunch of his OCaml projects, just like me.

+1
source share

I would add another Makefile for Ocaml, which I use for my projects.

Makefile and sample use are available on the Ocaml website .

0
source share

All Articles