From: Gerd S. <in...@ge...> - 2001-12-17 23:17:27
|
Sorry for the small mistakes. I was a bit tired when writing the instructions up. On 2001.12.16 19:20 Markus Mottl wrote: > Gerd Stolpmann schrieb am Sonntag, den 16. Dezember 2001: > > because ocamlnet depends on PCRE, I have tried to compile PCRE (4.8-1) as > > DLL. It works as follows: > > The newest version of PCRE for OCaml (4.10-1) uses an upgraded version > of Phil Hazel's PCRE-library. I am not sure whether this can make a > difference. > > > This make will fail (it cannot make pcretest). Look into pcre-C/.libs, > > and check if there is libpcre.so.0.0.1. If so, the part of the build we > > need has succeeded. > > Everything's fine up to here. > > > Now: > > > > cp .libs/libpcre.so.0.0.1 ../pcre-OCaml/dllpcre.so > > cp .libs/libpcre.a ../pcre-OCaml > > cd ../pcre-OCaml > > ocamlc pcre.mli > > ocamlc pcre.ml > > ocamlopt pcre.ml > > Shouldn't this be: > > ocamlc -c pcre.ml > ocamlopt -c pcre.ml Yes, of course. > > ocamlmklib -o pcre pcre.cma ocamlmklib -o pcre pcre.cmo is right. ocamlmklib has a strange interface. It appends the suffix (.cma or .cmxa) to the output name. > > ocamlmklib -o pcre pcre.cmx > > This doesn't seem to work: pcre.cma would obviously be overwritten > during reading. > > I am not sure what mode of installation the users would prefer most. > Maybe it would be better to have two separate shared libraries, one for > the C-library and another for the stubs? I have just taken my first look > at the documentation of the new ocamlmklib-tool and it would probably > work more smoothly this way. This may work, but see below. You can create dllpcre.so by ocamlmklib -o pcre pcre_intf.o -lpcre and this adds libpcre.so as dependent library. I think this is the reason why Xavier changed the naming conventions between OCaml 3.03 and 3.04; now all OCaml-specific libraries follow the name pattern dll*.<extension> so you can have a OCaml library dllpcre.so and a generic library libpcre.so. (Note that ocamlmklib -o pcre now creates dllpcre.so! It depends on the type of the other objects you give on the command line.) But: Many people already have pcre on their disk (especially the users of free OS), but probably the wrong version. It would not be a good idea forcing them to replace the system-wide library, and it can become difficult to have two shared libraries with the same name. I don't really know whether the PCRE stubs only work for certain PCRE versions, or whether they are generic enough such that they will work with every installed system-wide PCRE library. > If anybody manages to improve the build process such that a shared > PCRE-library is built automatically (if possible) in a portable way, > I'd be glad to add this to the PCRE-distribution... :) I think there are only two choices: - Have two libraries libpcre.so and dllpcre.so with the outlined problems - Because it is not possible to add objects later to a shared library, pcre_intf.o must be added to the command creating the shared library. There are again two ways: * Keep the current Makefile in pcre-C and patch it * Replace the whole Makefile in pcre-C with a self-written one. Especially drop libtool, it is not really helpful. Compile the C files with ocamlc -c; this will add the necessary -fPIC options, too. Make the shared library with ocamlmklib. I think the last alternative is by far the simplest one. I am able to compile PCRE and create the library with only two commands: ocamlc -ccopt -I. -c maketables.c study.c get.c pcre.c pcre_intf.c ocamlmklib -o pcre maketables.o study.o get.o pcre.o pcre_intf.o And these commands work on all platforms that support shared libraries under OCaml, so there is no need for libtool. Gerd -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 45 64293 Darmstadt EMail: ge...@ge... Germany ---------------------------------------------------------------------------- |