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/.

Advertisements

One thought on “Libraries with Ocaml

  1. 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

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s