| 1 |
karoline |
3951 |
Installation Notes for Windows XP/MinGW |
| 2 |
|
|
======================================= |
| 3 |
|
|
|
| 4 |
|
|
It is possible to compile CDuce under cygwin with the MinGW toolchain. |
| 5 |
|
|
Currently, the resulting executable still depends on the cygwin1.dll. |
| 6 |
|
|
The suspect is pcre, but the source of the "pollution" has not been |
| 7 |
|
|
determined. |
| 8 |
|
|
|
| 9 |
|
|
The dependencies can be checked with the "cygcheck" command under |
| 10 |
|
|
cygwin. Note that cygcheck searches in the PATH, i.e., if a binary is |
| 11 |
|
|
not in the path, one must give the full path. To check a binary in |
| 12 |
|
|
the mingw directory (e.g., C:\ocamlmgw\bin\cduce), one must give the |
| 13 |
|
|
Mingw path (C:/ocamlmgw/bin/cduce) to cygcheck, not the cygwin path |
| 14 |
|
|
(/cygdrive/c/ocamlmgw/bin). |
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
When compiling under the MinGW toolchain, the option -mno-cygwin must |
| 18 |
|
|
always be passed to the C compiler and linker. It is also necessary |
| 19 |
|
|
to ensure that one is not linking against any cygwin libraries at any |
| 20 |
|
|
point. The MinGW libraries are located in /usr/lib/... |
| 21 |
|
|
|
| 22 |
|
|
|
| 23 |
|
|
Steps: |
| 24 |
|
|
|
| 25 |
|
|
---------------------------------------------------------------------- |
| 26 |
|
|
1) In Cygwin, add the packages for MinGW support to the ones already |
| 27 |
|
|
mentioned in INSTALL.WIN32. |
| 28 |
|
|
|
| 29 |
|
|
gcc-mingw-core |
| 30 |
|
|
mingw-runtime |
| 31 |
|
|
w32-api |
| 32 |
|
|
<maybe more, which may be the cause of our problem?> |
| 33 |
|
|
|
| 34 |
|
|
Remove the prce packages from Cygwin, to make sure that the pcre |
| 35 |
|
|
used is the one installed under Mingw. |
| 36 |
|
|
|
| 37 |
|
|
|
| 38 |
|
|
---------------------------------------------------------------------- |
| 39 |
|
|
2) Install tcl/tk in Windows |
| 40 |
|
|
|
| 41 |
|
|
Install Tcl/Tk in a windows top directory, eg, C:\Tcl |
| 42 |
|
|
|
| 43 |
|
|
binaries available as described in ocaml notes (README.win32). |
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
|
---------------------------------------------------------------------- |
| 47 |
|
|
3) OCAML |
| 48 |
|
|
|
| 49 |
|
|
Build ocaml 3.10 for the mingw toolchain as specified in README.win32, |
| 50 |
|
|
but with the following addition from the ocaml mailing list: |
| 51 |
|
|
|
| 52 |
|
|
From: Arnold Guillaumot <arnold.guillaumot <at> snef.ro> |
| 53 |
|
|
Subject: Re: Compiling with Cygwin/MinGW |
| 54 |
|
|
Newsgroups: gmane.comp.lang.ocaml.lib.gtk |
| 55 |
|
|
Date: 2007-09-05 18:55:39 GMT |
| 56 |
|
|
|
| 57 |
|
|
Hi, |
| 58 |
|
|
|
| 59 |
|
|
I succeeded in the past to build ocaml and lablgtk with MinGW/MSYS |
| 60 |
|
|
(without Cygwin), together with ocamlmklib. |
| 61 |
|
|
In the ocaml tree, change the following files: |
| 62 |
|
|
|
| 63 |
|
|
1) ocamlmklib |
| 64 |
|
|
|
| 65 |
|
|
The 'trick' is to copy the Makefile part of ocamlmklib in the Makefile.nt |
| 66 |
|
|
|
| 67 |
|
|
edit tools/Makefile.nt and change the Line 26 |
| 68 |
|
|
all: ocamldep ocamlprof ocamlcp.exe ocamlmktop.exe primreq |
| 69 |
|
|
in |
| 70 |
|
|
all: ocamldep ocamlprof ocamlcp.exe ocamlmktop.exe primreq |
| 71 |
|
|
ocamlmklib.exe |
| 72 |
|
|
|
| 73 |
|
|
append the following lines after the ocamlmktop part: |
| 74 |
|
|
|
| 75 |
|
|
# To help building mixed-mode libraries (Caml + C) |
| 76 |
|
|
|
| 77 |
|
|
ocamlmklib.exe: myocamlbuild_config.cmo ocamlmklib.cmo |
| 78 |
|
|
$(CAMLC) $(LINKFLAGS) -o ocamlmklib.exe myocamlbuild_config.cmo |
| 79 |
|
|
ocamlmklib.cmo |
| 80 |
|
|
|
| 81 |
|
|
ocamlmklib.cmo: myocamlbuild_config.cmi |
| 82 |
|
|
myocamlbuild_config.ml: ../config/Makefile |
| 83 |
|
|
../build/mkmyocamlbuild_config.sh |
| 84 |
|
|
cp ../myocamlbuild_config.ml . |
| 85 |
|
|
|
| 86 |
|
|
install:: |
| 87 |
|
|
cp ocamlmklib.exe $(BINDIR)/ocamlmklib.exe |
| 88 |
|
|
|
| 89 |
|
|
clean:: |
| 90 |
|
|
rm -f ocamlmklib.exe |
| 91 |
|
|
|
| 92 |
|
|
ocamlmklib.ml: ocamlmklib.mlp ../config/Makefile |
| 93 |
|
|
echo '(* THIS FILE IS GENERATED FROM ocamlmklib.mlp *)' >ocamlmklib.ml |
| 94 |
|
|
sed -e "s|%%BINDIR%%|$(BINDIR)|" \ |
| 95 |
|
|
-e |
| 96 |
|
|
"s|%%SUPPORTS_SHARED_LIBRARIES%%|$(SUPPORTS_SHARED_LIBRARIES)|" \ |
| 97 |
|
|
-e "s|%%MKSHAREDLIB%%|$(MKSHAREDLIB)|" \ |
| 98 |
|
|
-e "s|%%BYTECCRPATH%%|$(BYTECCRPATH)|" \ |
| 99 |
|
|
-e "s|%%NATIVECCRPATH%%|$(NATIVECCRPATH)|" \ |
| 100 |
|
|
-e "s|%%MKSHAREDLIBRPATH%%|$(MKSHAREDLIBRPATH)|" \ |
| 101 |
|
|
-e "s|%%RANLIB%%|$(RANLIB)|" \ |
| 102 |
|
|
ocamlmklib.mlp >> ocamlmklib.ml |
| 103 |
|
|
|
| 104 |
|
|
beforedepend:: ocamlmklib.ml |
| 105 |
|
|
|
| 106 |
|
|
clean:: |
| 107 |
|
|
rm -f ocamlmklib.ml |
| 108 |
|
|
|
| 109 |
|
|
It seems that this is not in the ocaml distribution because it doesn't |
| 110 |
|
|
work under MSVS, only under MinGW, and since there is only one |
| 111 |
|
|
Makefile.nt... |
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
adjust PATH: |
| 115 |
|
|
|
| 116 |
|
|
PATH=$PATH:/cygdrive/c/ocamlmgw/bin |
| 117 |
|
|
|
| 118 |
|
|
|
| 119 |
|
|
---------------------------------------------------------------------- |
| 120 |
|
|
4) findlib |
| 121 |
|
|
|
| 122 |
|
|
Patch configure replacing |
| 123 |
|
|
stdlib = `get_stdlib` |
| 124 |
|
|
with |
| 125 |
|
|
stdlib = /cygdrive/c/ocamlmgw/lib |
| 126 |
|
|
|
| 127 |
|
|
./configure -bindir /cygdrive/c/ocamlmgw/bin |
| 128 |
|
|
|
| 129 |
|
|
Patch Makefile.config replacing |
| 130 |
|
|
OCAML_CORE_MAN = /usr/local/man |
| 131 |
|
|
with |
| 132 |
|
|
OCAML_CORE_MAN = /cygdrive/c/ocamlmgw/man |
| 133 |
|
|
(since ocaml for mingw does not install the man directories, the |
| 134 |
|
|
mandir option does not work). |
| 135 |
|
|
|
| 136 |
|
|
make all |
| 137 |
|
|
make opt |
| 138 |
|
|
make install |
| 139 |
|
|
|
| 140 |
|
|
|
| 141 |
|
|
---------------------------------------------------------------------- |
| 142 |
|
|
5) ulex |
| 143 |
|
|
|
| 144 |
|
|
This gets stuck with the error "can't found ocamlbuildlib.cma in |
| 145 |
|
|
ocamlbuild -where", which is not surprising, since ocamlbuild -where |
| 146 |
|
|
returns /ocamlbuildlib/lib, which doesn't exist. See ocaml bug 4379. |
| 147 |
|
|
This is supposedly fixed in ocaml 3.10.1, but it still doesn't seem to |
| 148 |
|
|
work. |
| 149 |
|
|
|
| 150 |
|
|
Until this bug is fixed, patch Makefile to use |
| 151 |
|
|
|
| 152 |
|
|
ocamlbuild -install-lib-dir "C:\ocamlmgw\lib\ocamlbuild" |
| 153 |
|
|
|
| 154 |
|
|
(or whereever your mingw installation is). This workaround is |
| 155 |
|
|
suitable for cygwin, but it may not work in Mingw/MSYS. |
| 156 |
|
|
|
| 157 |
|
|
Remember to also add -classic-display to ocamlbuild, since we are |
| 158 |
|
|
building with ocaml 3.10. |
| 159 |
|
|
|
| 160 |
|
|
make all |
| 161 |
|
|
make all.opt |
| 162 |
|
|
make install |
| 163 |
|
|
|
| 164 |
|
|
|
| 165 |
|
|
---------------------------------------------------------------------- |
| 166 |
|
|
6) PCRE: |
| 167 |
|
|
|
| 168 |
|
|
Since the pcre that comes with cygwin cannot be used in mingw, install |
| 169 |
|
|
pcre before pcre-ocaml. This is simpler if pcre is not installed in |
| 170 |
|
|
cygwin. |
| 171 |
|
|
|
| 172 |
|
|
Go back to cygwin's setup.exe and install gcc-g++ (C++ compiler). |
| 173 |
|
|
|
| 174 |
|
|
Download pcre-7.2 from www.pcre.org or |
| 175 |
|
|
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre |
| 176 |
|
|
|
| 177 |
|
|
To configure pcre-7.2: |
| 178 |
|
|
|
| 179 |
|
|
If pcre is installed in cygwin, patch ltmain.sh so that need_relink is |
| 180 |
|
|
always "no", that may avoid the cygwin dependency. |
| 181 |
|
|
|
| 182 |
|
|
./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" |
| 183 |
|
|
|
| 184 |
|
|
Patch the Makefile to replace cygwin with mingw everywhere it occurs |
| 185 |
|
|
(except in -mno-cygwin). |
| 186 |
|
|
|
| 187 |
|
|
Patch the libtool file similarly. |
| 188 |
|
|
|
| 189 |
|
|
make |
| 190 |
|
|
|
| 191 |
|
|
make install |
| 192 |
|
|
|
| 193 |
|
|
This installs the libs in the ocaml mingw directory |
| 194 |
|
|
(e.g. C:\ocamlmgw\lib, but the .h files in /usr/include/mingw. This |
| 195 |
|
|
should be suitable for continued compilation using the mingw |
| 196 |
|
|
toolchain, but not for a pure mingw compilation. |
| 197 |
|
|
|
| 198 |
|
|
Check with cygcheck whether, eg, pcregrep.exe, depends on the |
| 199 |
|
|
cygwin1.dll and cygpcre-0.dll. |
| 200 |
|
|
---------------------------------------------------------------------- |
| 201 |
|
|
7) pcre-ocaml: |
| 202 |
|
|
|
| 203 |
|
|
Edit Makefile.conf to contain |
| 204 |
|
|
|
| 205 |
|
|
export STATIC = yes |
| 206 |
|
|
export INCDIRS := /usr/include/mingw |
| 207 |
|
|
export LIBDIRS := C:/ocamlmgw/lib |
| 208 |
|
|
MINGW=1 |
| 209 |
|
|
CC=gcc |
| 210 |
|
|
export GCC |
| 211 |
|
|
export MINGW |
| 212 |
|
|
|
| 213 |
|
|
(If cc is not set, it defaults to cc, which causes 'make' to fail |
| 214 |
|
|
spectacularly during |
| 215 |
|
|
|
| 216 |
|
|
ocamlc -c -cc "cc" -ccopt "-fPIC -O2 -DPIC -mno-cygwin -I /usr/include/mingw -o pcre_stubs.o" pcre_stubs.c |
| 217 |
|
|
|
| 218 |
|
|
sometimes even to the point of crashing cygwin.) |
| 219 |
|
|
|
| 220 |
|
|
make |
| 221 |
|
|
make install |
| 222 |
|
|
|
| 223 |
|
|
The file pcre_make.win32/Makefile.mingw does not seem to work, either |
| 224 |
|
|
it is for Mingw/MSYS or it has not been updated. |
| 225 |
|
|
|
| 226 |
|
|
The file README.win32 concerns MS Visual Studio, i.e., it is |
| 227 |
|
|
irrelevant. |
| 228 |
|
|
|
| 229 |
|
|
To check that pcre actually works in ocaml: |
| 230 |
|
|
|
| 231 |
|
|
make a file foo.ml that uses Pcre, eg |
| 232 |
|
|
|
| 233 |
|
|
open Prce;; |
| 234 |
|
|
qreplace;; |
| 235 |
|
|
|
| 236 |
|
|
compile it with |
| 237 |
|
|
|
| 238 |
|
|
ocamlc -I "C:/ocamlmgw/lib/site-lib/pcre" foo.ml |
| 239 |
|
|
|
| 240 |
|
|
---------------------------------------------------------------------- |
| 241 |
|
|
8) pxp |
| 242 |
|
|
|
| 243 |
|
|
./configure -without-wlex -without-wlex-compat -lexlist utf8,iso88591 -without-pp |
| 244 |
|
|
|
| 245 |
|
|
make all |
| 246 |
|
|
make opt |
| 247 |
|
|
make install |
| 248 |
|
|
|
| 249 |
|
|
|
| 250 |
|
|
---------------------------------------------------------------------- |
| 251 |
|
|
9) CDuce |
| 252 |
|
|
|
| 253 |
|
|
./configure --prefix="C:/ocamlmgw" --mliface="C:/cygwin/usr/src/ocaml-3.10.0/" |
| 254 |
|
|
|
| 255 |
|
|
patch Makefile.conf to set FORPACK=true |
| 256 |
|
|
(For some reason that fails in configure.ml) |
| 257 |
|
|
|
| 258 |
|
|
Patch Makefile.distrib to set |
| 259 |
|
|
|
| 260 |
|
|
LINK = $(CAMLOPT) -custom -linkpkg |
| 261 |
|
|
|
| 262 |
|
|
in line 71 to statically link the library. |
| 263 |
|
|
|
| 264 |
|
|
|
| 265 |
|
|
make all |
| 266 |
|
|
make install |