From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA18143; Thu, 6 Sep 2001 23:43:38 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA18017 for ; Thu, 6 Sep 2001 23:43:38 +0200 (MET DST) Received: from moutvdom01.kundenserver.de (moutvdom01.kundenserver.de [195.20.224.200]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f86Lhbr12043 for ; Thu, 6 Sep 2001 23:43:37 +0200 (MET DST) Received: from [195.20.224.209] (helo=mrvdom02.schlund.de) by moutvdom01.kundenserver.de with esmtp (Exim 2.12 #2) id 15f6vx-0000C0-00 for caml-list@inria.fr; Thu, 6 Sep 2001 23:43:37 +0200 Received: from drms-3e364bb0.pool.mediaways.net ([62.54.75.176] helo=ice.gerd-stolpmann.de) by mrvdom02.schlund.de with esmtp (Exim 2.12 #2) id 15f6vw-0000NW-00 for caml-list@inria.fr; Thu, 6 Sep 2001 23:43:36 +0200 Received: from localhost (localhost [[UNIX: localhost]]) by ice.gerd-stolpmann.de (8.9.3/8.9.3) id XAA27292 for caml-list@inria.fr; Thu, 6 Sep 2001 23:43:20 +0200 From: Gerd Stolpmann Reply-To: info@gerd-stolpmann.de Organization: privat To: ocaml Subject: Re: [Caml-list] How to use pcre (3) Date: Thu, 6 Sep 2001 23:28:31 +0200 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain References: <87pu94lbdt.fsf@bywoner.sun.ac.za> <20010906164530.F24260@chopin.ai.univie.ac.at> <87heug5c81.fsf_-_@adept.co.za> In-Reply-To: <87heug5c81.fsf_-_@adept.co.za> MIME-Version: 1.0 Message-Id: <01090623430915.02716@ice> Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 06 Sep 2001, Johann Spies wrote: >Markus Mottl 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;; >print_newline();; >-------------------------- > >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 -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 45 64293 Darmstadt EMail: gerd@gerd-stolpmann.de Germany ---------------------------------------------------------------------------- ------------------- 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