English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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:43)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] How to use pcre (3)
On Thu, 06 Sep 2001, Johann Spies wrote:
>Markus Mottl <markus@mail4.ai.univie.ac.at> writes:
>> This is an FAQ and not related to the Pcre in particular: the problem
>> is that
>Maybe a FAQ, but difficult for newbies to know when and how.  
>>   a) you have to build a "customized" toplevel, because a C-library
>>      has to be linked in. This is very easy:
>After a bit of experimentation I got this to work.
>After about another hour and a half I did not succeed in compiling the
>following program:
>let s = "abcde";;
>let t = Pcre.replace ~pat:"c" ~templ:" Hier gebeur 'n ding " s;;
>print_string t;;
>I have read the man page for ocamlopt as well as the ocaml manual and
>still do not know how to compile it!?  Maybe I am just dumb.
>My latest effort was:
>$ocamlfind ocamlopt -o rex -I /usr/lib/ocaml/contrib -ccopt
>-L/usr/lib/ocaml/contrib  -cclib -llibpcre.a -linkall /tmp/rex.ml
>No implementations provided for the following modules:
>  Pcre referenced from /tmp/rex.cmx
>The usage of ocamlfind made no difference.

ocamlopt -o rex -I /usr/lib/ocaml/contrib pcre.cmxa /tmp/rex.ml

SHOULD suffice. Perhaps you need the -ccopt and -cclib options, too, that
depends on how clever pcre is installed (can't remember) (oh, and it's -lpcre,
not -llibpcre.a, if you need it).

You seem to be confused because there are two .a files, arent't you:
libpcre.a and pcre.a. Actually, both are needed in the final executable, i.e.
both contain necessary machine code. Fortutately, there is also the .cmxa file
which only contains management information, and no machine code, and if you
put it onto the command line the compiler will always be able to find the
pcre.a file at least, and if you are lucky, it will also find libpcre.a. (The
latter works only if pcre is installed with "automatic linking", I don't know
whether the current release supports it.) pcre.a contains compiled ocaml code,
and libpcre.a contains compiled C code.

ocamlfind makes only a difference if the pcre installation contains a so-called
META file, and in this case you could do: ocamlfind ocamlopt -o rex -package
pcre -linkpkg /tmp/rex.ml. That's for people who like it comfortable (here in
Germany we say "Warmduscher", don't know how to translate it).

Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 45             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr