Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] How to use pcre
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-06 (21:24)
From: Markus Mottl <markus@m...>
Subject: Re: [Caml-list] How to use pcre (3)
On Thu, 06 Sep 2001, Johann Spies wrote:
> After about another hour and a half I did not succeed in compiling the
> following program:
> My latest effort was:
> $ocamlfind ocamlopt -o rex -I /usr/lib/ocaml/contrib -ccopt
> -L/usr/lib/ocaml/contrib  -cclib -llibpcre.a -linkall /tmp/

The problem is that you have to add pcre.cmxa (or pcre.cma for byte code)
before your /tmp/ It's not enough to link against the C-library,
or better: you don't even have to do this.

This should suffice:

  ocamlopt -o rex -I /usr/lib/ocaml/contrib -ccopt \
    -L/usr/lib/ocaml/contrib pcre.cmxa /tmp/

I don't know ocamlfind, because I usually use OcamlMakefile for just
about anything. If you want to try the latter, you'd write a Makefile
that might look like this:

RESULT = rex
LIBS = pcre
-include OcamlMakefile

You'd only have to set an environment variable (e.g. either in
the Makefile itself or globally in you .bashrc or similar) named
OCAML_DEFAULT_DIRS, which can be any number of paths that contain your
favourite OCaml-libraries.

I usually define a shell alias that just copies a suitable template of
such a Makefile into the current directory so that I can experiment fast.
OcamlMakefile is somewhere in my home directory and is automatically
loaded if you start make as "make -I {path to generic Makefiles}". The
latter can, again, be aliased.

Once I find a bit more time, I'll explain such small (but
useful!) development speedups on my upcoming OCaml hint page...

Markus Mottl

Markus Mottl                                   
Austrian Research Institute
for Artificial Intelligence        
Bug reports:  FAQ:
To unsubscribe, mail  Archives: