Libraries with Ocaml

I’ve been trying to learn a little more about Ocaml, since functional programming is so frequently marketed as solving a lot of today’s bad programming practices that lead to vulnerabilities and security problems.

I’ve been going through the Ocaml Tutorial but the instructions for building grtest1.ml were insufficient:

$ ocamlc grtest1.ml -o grtest1
Error while linking grtest1.cmo: Reference to undefined global `Graphics’

I needed to specify the name of the library I’m using:

$ ocamlc graphics.cma grtest1.ml -o grtest1

which on my Mac OS X system comes from /usr/local/lib/ocaml/.

One Response to “Libraries with Ocaml”

  1. yoric Says:

    You could also write a one-line configuration file called _tags containing

    <*>: use_graphics

    and then write

    $ ocamlbuild grtest1.byte

    OCamlBuild rocks seriously.

Leave a Reply

You must be logged in to post a comment.