Commit aaf331fa authored by Karoline Malmkjaer's avatar Karoline Malmkjaer
Browse files

Installation notes for the mingw toolchain in cygwin. Incomplete, as

the result is still cygwin dependable.
parent 378ead87
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
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
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/...
1) In Cygwin, add the packages for MinGW support to the ones already
mentioned in INSTALL.WIN32.
<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).
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>>
Subject: Re: Compiling with Cygwin/MinGW
Newsgroups: gmane.comp.lang.ocaml.lib.gtk
Date: 2007-09-05 18:55:39 GMT
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
all: ocamldep ocamlprof ocamlcp.exe ocamlmktop.exe primreq
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: myocamlbuild_config.cmi ../config/Makefile
cp ../ .
cp ocamlmklib.exe $(BINDIR)/ocamlmklib.exe
rm -f ocamlmklib.exe ocamlmklib.mlp ../config/Makefile
echo '(* THIS FILE IS GENERATED FROM ocamlmklib.mlp *)' >
sed -e "s|%%BINDIR%%|$(BINDIR)|" \
-e "s|%%RANLIB%%|$(RANLIB)|" \
ocamlmklib.mlp >>
rm -f
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
adjust PATH:
4) findlib
Patch configure replacing
stdlib = `get_stdlib`
stdlib = /cygdrive/c/ocamlmgw/lib
./configure -bindir /cygdrive/c/ocamlmgw/bin
Patch Makefile.config replacing
OCAML_CORE_MAN = /usr/local/man
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
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
Go back to cygwin's setup.exe and install gcc-g++ (C++ compiler).
Download pcre-7.2 from or
To configure pcre-7.2:
If pcre is installed in cygwin, patch 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 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
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 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
To check that pcre actually works in ocaml:
make a file that uses Pcre, eg
open Prce;;
compile it with
ocamlc -I "C:/ocamlmgw/lib/site-lib/pcre"
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
Patch Makefile.distrib to set
LINK = $(CAMLOPT) -custom -linkpkg
in line 71 to statically link the library.
make all
make install
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment