From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 6A032BBC4 for ; Fri, 20 Feb 2009 15:28:33 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkwCAINMnklRZ90xkWdsb2JhbACOC4ZMAQEBAQkLCgcRA78thA8G X-IronPort-AV: E=Sophos;i="4.38,241,1233529200"; d="scan'208";a="24437349" Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]) by mail1-smtp-roc.national.inria.fr with ESMTP; 20 Feb 2009 15:28:32 +0100 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090220142828.OXML7670.mtaout03-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Fri, 20 Feb 2009 14:28:28 +0000 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090220142828.GKDK21638.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com> for ; Fri, 20 Feb 2009 14:28:28 +0000 Received: from Tenor (genkt-048-066.t-mobile.co.uk.254.149.in-addr.arpa [149.254.48.66] (may be forged)) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id n1KESIhN023219 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 20 Feb 2009 14:28:21 GMT From: "David Allsopp" To: "OCaml List" Subject: Building pcre-ocaml on OCaml 3.11.0 on MinGW Date: Fri, 20 Feb 2009 14:28:15 -0000 Organization: MetaStack Solutions Ltd. Message-ID: <001801c99367$7a56e740$6f04b5c0$@com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0019_01C99367.7A56E740" X-Mailer: Microsoft Office Outlook 12.0 thread-index: AcmTRmK894195K4IT5maIXSU7aOeww== Content-Language: en-gb X-Scanned-By: MIMEDefang 2.64 on 81.102.132.74 X-Cloudmark-Analysis: v=1.0 c=1 a=zuyBMW-Da5wA:10 a=iFG2TseAOn4A:10 a=FyGCXJYSKQ1WRW0MSt0A:9 a=08J7RgZ6VHanFFXVpcUA:7 a=J9yRQQg6HPfekSMJ-UOZFE-aSy4A:4 a=CWfAmLVWKswA:10 a=EgEUkmQnw0TQgXszyJkA:9 a=Eiq41ug66HXBOxXOjUP6a5jLIvUA:4 a=NfA2RSpTaHsA:10 X-Spam: no; 0.00; pcre-ocaml:01 ocaml:01 mingw:01 pcre-ocaml:01 pcre:01 ocaml:01 cduce:01 libpcre:01 libpcre:01 mingw:01 cygwin:01 pcre:01 --prefix:01 lib:01 alain's:01 X-Attachments: type="application/octet-stream" name="pcre-ocaml-release-5.15.1.patch" name="pcre-ocaml-release-5.15.1.patch" This is a multipart message in MIME format. ------=_NextPart_000_0019_01C99367.7A56E740 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I've just had an enlightening few hours getting pcre-ocaml to compile under Windows (I tried a few years ago and, very lazily, just gave up). I've managed to get it to work but I'm wondering whether anyone else has done this and, if so, whether they can explain/confirm/correct a couple of the steps involved. I'm very much indebted to Alain Frisch's instructions for building PCRE under OCaml 3.10.0 which are part of the CDuce distribution or I would've been completely at sea with this! The main thing that's got me puzzled is the renaming of libpcre.dll.a and libpcre.a that I have to do to get the thing to link. Note that I'm building the "official" way - so MinGW running within Cygwin. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ Building pcre for MinGW (Ensure that Cygwin's PCRE libraries are *not* installed) Unpacked PCRE 7.8 ./configure --prefix="C:/Dev/OCaml" \ # set to install PCRE --includedir="C:/Dev/OCaml/lib" \ # to my OCaml tree. --disable-cpp \ # from Alain's instructions. --enable-utf8 \ # Similarly. --build=mingw32 \ # MinGW, not Cygwin build CC="gcc -mno-cygwin" # Necessary to ensure that # autoconf detects the correct # library and include dirs # when querying gcc (CFLAGS # won't work here) make make install ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ Building pcre-ocaml (Note that with older (< 0.14) versions of flexlink, the linker errors noted doesn't show up and the resulting library is broken) Unpacked pcre-ocaml 5.15.1 Edit pcre-ocaml-release-5.15.1/Makefile.conf to contain: export LIBDIRS := C:/Dev/OCaml/lib # Location of PCRE export MINGW=1 # MinGW build export CC=gcc # Or you get lots of errors! patch -p0 -i pcre-ocaml-release-5.15.1.patch # (attached) The patch "fixes" two things in OCamlMakefile a) It causes the ocamlc -where check to pass the result through cygpath. My OCAMLLIB variable is correctly set (for Windows) as C:\Dev\OCaml\lib and Cygwin configure scripts should generally respect that (build in Cygwin, run in Windows so OCAMLLIB is a Windows environment variable...). I've been lazy though and not done the same thing for the camlp4 -where test... b) It adds a simple check for OCaml 3.11 (it would be better if it did a >= 3.11 check but I haven't bothered to bring up the GNU make info pages to check the syntax for doing that!) and uses ocamlmklib instead of manually building the stub libraries if OCaml 3.11 is found - the manual build instructions included in OCamlMakefile are for 3.10 and earlier and so don't work (i.e. non-flexlink linking) OK, so at this stage it looks as though we should be ready to build. But if I run make (with flexlink 0.14 or later) then I get the following errors (compiling with flexlink 0.13 works, but the resulting library is broken): ocamlmklib -LC:/Dev/OCaml/lib -o pcre_stubs pcre_stubs.o -lpcre c:\Users\DRA\AppData\Local\Temp\dyndll8e6a10.o:pcre_stubs.c:(.text+0x205): undefined reference to `__imp__pcre_callout' [and several more missing __imp__pcre_... messages] The problem is in C:\Dev\OCaml\lib, it appears. In there are libpcre.a, libpcre.dll.a and libpcre.la. If I rename libpcre.a to libpcre.old.a and then libpcre.dll.a to libpcre.a then the build works and the resulting library builds. As far as I can tell, this is something to do with libtool but I know very little about this - is the inability of the library to link without renaming these files something to do with using flexlink as the linker? If I link a test program in C using -lpcre then it works - but is that because gcc knows how to read .la files and looks for the libpcre.dll.a file correctly? However, once this is followed through, the library does correctly build and install - and the examples all seem to be working. So, finally, it's cheerio to the Str module for me :o) Any pointers appreciated! David ------=_NextPart_000_0019_01C99367.7A56E740 Content-Type: application/octet-stream; name="pcre-ocaml-release-5.15.1.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pcre-ocaml-release-5.15.1.patch" diff -Naur pcre-ocaml-release-5.15.1/OCamlMakefile = pcre-ocaml-release-5.15.1.new/OCamlMakefile=0A= --- pcre-ocaml-release-5.15.1/OCamlMakefile 2008-11-29 = 05:30:56.000000000 +0000=0A= +++ pcre-ocaml-release-5.15.1.new/OCamlMakefile 2009-02-20 = 09:55:37.659000000 +0000=0A= @@ -352,11 +352,20 @@=0A= export OCAMLMAKEFILE=0A= =0A= ifndef OCAMLLIBPATH=0A= +ifdef WIN32=0A= + OCAMLLIBPATH :=3D \=0A= + $(shell cygpath -u `$(OCAMLC) 2>/dev/null -where` || echo = /cygdrive/c/ocamlmgw)=0A= +else=0A= OCAMLLIBPATH :=3D \=0A= $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/local/lib/ocaml)=0A= endif=0A= +endif=0A= export OCAMLLIBPATH=0A= =0A= +ifeq ($(shell ocamlc -config | fgrep "version: 3.11" > /dev/null && = echo 1), 1)=0A= + OCAML311 :=3D 1=0A= +endif=0A= +=0A= ifndef OCAML_LIB_INSTALL=0A= OCAML_LIB_INSTALL :=3D $(OCAMLLIBPATH)/contrib=0A= endif=0A= @@ -481,7 +490,12 @@=0A= endif=0A= =0A= ifdef WIN32=0A= +# @@DRA Not sure that this shouldn't always be dll$(CLIB_BASE).dll?=0A= +ifdef OCAML311=0A= +DLLSONAME :=3D dll$(CLIB_BASE).dll=0A= +else=0A= DLLSONAME :=3D $(CLIB_BASE).dll=0A= +endif=0A= else=0A= DLLSONAME :=3D dll$(CLIB_BASE).so=0A= endif=0A= @@ -897,12 +911,19 @@=0A= =0A= ifndef STATIC=0A= ifdef MINGW=0A= +ifdef OCAML311=0A= +$(DLLSONAME): $(OBJ_LINK)=0A= + $(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \=0A= + -o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=3D-l%) = $(CFRAMEWORKS:%=3D-framework %) \=0A= + $(OCAMLMKLIB_FLAGS)=0A= +else=0A= $(DLLSONAME): $(OBJ_LINK)=0A= $(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \=0A= -Wl,--whole-archive $(wildcard $(foreach = dir,$(LIBDIRS),$(CLIBS:%=3D$(dir)/lib%.a))) \=0A= $(OCAMLLIBPATH)/ocamlrun.a \=0A= -Wl,--export-all-symbols \=0A= -Wl,--no-whole-archive=0A= +endif=0A= else=0A= ifdef MSVC=0A= $(DLLSONAME): $(OBJ_LINK)=0A= ------=_NextPart_000_0019_01C99367.7A56E740--