INSTALL.mingw 7.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
                 Installation Notes for Windows XP/MinGW
                 =======================================

It is possible to compile CDuce under cygwin with the MinGW toolchain.
Currently, the resulting executable still depends on the cygwin1.dll.
The suspect is pcre, but the source of the "pollution" has not been
determined.

The dependencies can be checked with the "cygcheck" command under
cygwin.  Note that cygcheck searches in the PATH, i.e., if a binary is
not in the path, one must give the full path.  To check a binary in
the mingw directory (e.g., C:\ocamlmgw\bin\cduce), one must give the
Mingw path (C:/ocamlmgw/bin/cduce) to cygcheck, not the cygwin path
(/cygdrive/c/ocamlmgw/bin).


When compiling under the MinGW toolchain, the option -mno-cygwin must
always be passed to the C compiler and linker.  It is also necessary
to ensure that one is not linking against any cygwin libraries at any
point.  The MinGW libraries are located in /usr/lib/...


Steps:

----------------------------------------------------------------------
1) In Cygwin, add the packages for MinGW support to the ones already
   mentioned in INSTALL.WIN32.

   gcc-mingw-core
   mingw-runtime
   w32-api
   <maybe more, which may be the cause of our problem?>
   
   Remove the prce packages from Cygwin, to make sure that the pcre
   used is the one installed under Mingw.


----------------------------------------------------------------------
2) Install tcl/tk in Windows

   Install Tcl/Tk in a windows top directory, eg, C:\Tcl

   binaries available as described in ocaml notes (README.win32).


----------------------------------------------------------------------
3) OCAML

Build ocaml 3.10 for the mingw toolchain as specified in README.win32,
but with the following addition from the ocaml mailing list:

    From: Arnold Guillaumot <arnold.guillaumot <at> snef.ro>
    Subject: Re: Compiling with Cygwin/MinGW
    Newsgroups: gmane.comp.lang.ocaml.lib.gtk
    Date: 2007-09-05 18:55:39 GMT

    Hi,

    I succeeded in the past to build ocaml and lablgtk with MinGW/MSYS
    (without Cygwin), together with ocamlmklib.
    In the ocaml tree, change the following files:

    1) ocamlmklib

    The 'trick' is to copy the Makefile part of ocamlmklib in the Makefile.nt

    edit tools/Makefile.nt and change the Line 26
         all: ocamldep ocamlprof ocamlcp.exe ocamlmktop.exe primreq
         in
         all: ocamldep ocamlprof ocamlcp.exe ocamlmktop.exe primreq
    ocamlmklib.exe

    append the following lines after the ocamlmktop part:

    # To help building mixed-mode libraries (Caml + C)

    ocamlmklib.exe: myocamlbuild_config.cmo ocamlmklib.cmo
        $(CAMLC) $(LINKFLAGS) -o ocamlmklib.exe myocamlbuild_config.cmo
    ocamlmklib.cmo

    ocamlmklib.cmo: myocamlbuild_config.cmi
    myocamlbuild_config.ml: ../config/Makefile
        ../build/mkmyocamlbuild_config.sh
        cp ../myocamlbuild_config.ml .

    install::
        cp ocamlmklib.exe $(BINDIR)/ocamlmklib.exe

    clean::
        rm -f ocamlmklib.exe

    ocamlmklib.ml: ocamlmklib.mlp ../config/Makefile
        echo '(* THIS FILE IS GENERATED FROM ocamlmklib.mlp *)' >ocamlmklib.ml
        sed -e "s|%%BINDIR%%|$(BINDIR)|" \
                -e
    "s|%%SUPPORTS_SHARED_LIBRARIES%%|$(SUPPORTS_SHARED_LIBRARIES)|" \
                -e "s|%%MKSHAREDLIB%%|$(MKSHAREDLIB)|" \
                -e "s|%%BYTECCRPATH%%|$(BYTECCRPATH)|" \
                -e "s|%%NATIVECCRPATH%%|$(NATIVECCRPATH)|" \
                -e "s|%%MKSHAREDLIBRPATH%%|$(MKSHAREDLIBRPATH)|" \
                -e "s|%%RANLIB%%|$(RANLIB)|" \
              ocamlmklib.mlp >> ocamlmklib.ml

    beforedepend:: ocamlmklib.ml

    clean::
        rm -f ocamlmklib.ml

It seems that this is not in the ocaml distribution because it doesn't
work under MSVS, only under MinGW, and since there is only one
Makefile.nt...


adjust PATH:

PATH=$PATH:/cygdrive/c/ocamlmgw/bin


----------------------------------------------------------------------
4) findlib

  Patch configure replacing 
    stdlib = `get_stdlib`
  with 
    stdlib = /cygdrive/c/ocamlmgw/lib

  ./configure -bindir /cygdrive/c/ocamlmgw/bin

  Patch Makefile.config replacing
    OCAML_CORE_MAN = /usr/local/man
  with
    OCAML_CORE_MAN = /cygdrive/c/ocamlmgw/man
  (since ocaml for mingw does not install the man directories, the
  mandir option does not work).

  make all
  make opt
  make install


----------------------------------------------------------------------
5) ulex

This gets stuck with the error "can't found ocamlbuildlib.cma in
ocamlbuild -where", which is not surprising, since ocamlbuild -where
returns /ocamlbuildlib/lib, which doesn't exist.  See ocaml bug 4379.
This is supposedly fixed in ocaml 3.10.1, but it still doesn't seem to
work.

Until this bug is fixed, patch Makefile to use 

  ocamlbuild -install-lib-dir "C:\ocamlmgw\lib\ocamlbuild"

(or whereever your mingw installation is).  This workaround is
suitable for cygwin, but it may not work in Mingw/MSYS.

Remember to also add -classic-display to ocamlbuild, since we are
building with ocaml 3.10.

  make all
  make all.opt
  make install


----------------------------------------------------------------------
6) PCRE:

Since the pcre that comes with cygwin cannot be used in mingw, install
pcre before pcre-ocaml.  This is simpler if pcre is not installed in
cygwin.

Go back to cygwin's setup.exe and install gcc-g++ (C++ compiler).

Download pcre-7.2 from www.pcre.org or
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre

To configure pcre-7.2:

If pcre is installed in cygwin, patch ltmain.sh so that need_relink is
always "no", that may avoid the cygwin dependency.

./configure --prefix="C:/ocamlmgw" --exec-prefix="C:/ocamlmgw" --includedir=/usr/include/mingw --disable-cpp --enable-utf8 CFLAGS="-mno-cygwin -I /usr/include/w32api -I /usr/include/mingw"

Patch the Makefile to replace cygwin with mingw everywhere it occurs
(except in -mno-cygwin).

Patch the libtool file similarly.

make

make install

This installs the libs in the ocaml mingw directory
(e.g. C:\ocamlmgw\lib, but the .h files in /usr/include/mingw.  This
should be suitable for continued compilation using the mingw
toolchain, but not for a pure mingw compilation.

Check with cygcheck whether, eg, pcregrep.exe, depends on the
cygwin1.dll and cygpcre-0.dll.
----------------------------------------------------------------------
7) pcre-ocaml:

Edit Makefile.conf to contain

export STATIC = yes
export INCDIRS := /usr/include/mingw
export LIBDIRS := C:/ocamlmgw/lib
MINGW=1
CC=gcc
export GCC
export MINGW

(If cc is not set, it defaults to cc, which causes 'make' to fail
spectacularly during

ocamlc -c -cc "cc" -ccopt "-fPIC -O2 -DPIC -mno-cygwin -I /usr/include/mingw -o pcre_stubs.o" pcre_stubs.c

sometimes even to the point of crashing cygwin.)

make
make install

The file pcre_make.win32/Makefile.mingw does not seem to work, either
it is for Mingw/MSYS or it has not been updated.

The file README.win32 concerns MS Visual Studio, i.e., it is
irrelevant.

To check that pcre actually works in ocaml:

  make a file foo.ml that uses Pcre, eg

  open Prce;;
  qreplace;;

  compile it with 

  ocamlc -I "C:/ocamlmgw/lib/site-lib/pcre" foo.ml

----------------------------------------------------------------------
8) pxp

   ./configure -without-wlex -without-wlex-compat -lexlist utf8,iso88591 -without-pp

   make all
   make opt
   make install


----------------------------------------------------------------------
9) CDuce

./configure --prefix="C:/ocamlmgw" --mliface="C:/cygwin/usr/src/ocaml-3.10.0/" 

patch Makefile.conf to set FORPACK=true
(For some reason that fails in configure.ml)

Patch Makefile.distrib to set

LINK = $(CAMLOPT) -custom -linkpkg

in line 71 to statically link the library.


make all
make install