- Cygwin Setup
First, install Cygwin using the Cygwin installer(setup.exe). I set the Root directory toC:\Cygwin
and chose to install the following packages in addition to base packages.- bison
- gettext-devel
- libtool
- make
- mingw64-i686-binutils
- mingw64-i686-gcc-core
- mingw64-i686-gcc-fortran
- mingw64-i686-gcc-g++
- patch
- pkg-config
- bison
- Compile zlib and bzip2
Download the zlib source (zlib-1.2.7.tar.gz) and unpack it.tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
Compile and install zlib.make -f win32/Makefile.gcc
cp -iv zlib1.dll /mingw/bin
cp -iv zconf.h zlib.h /mingw/include
cp -iv libz.a /mingw/lib
cp -iv libz.dll.a /mingw/lib
Now download bzip2 source from bzip2.org and unpack it.tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
Change line 78 of bzlib.h to read:#if defined(_WIN32) && !defined(__MINGW32__)
Compile and install bzip2.make
cp bzlib.h /mingw/include/
cp libbz2.a /mingw/lib - libiconv
Download and compile libiconv:tar xzvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --build=i686-w64-mingw32 --prefix=/mingw --enable-static
make
make install - JPEG, PNG & Freetype
Compile JPEG, libPNG and Freetype in the following way:./configure --build=i686-w64-mingw32 --prefix=/mingw
make
make install - GD Graphics Library
Now get the libgd source, unpack and configure:./configure --build=i686-w64-mingw32 --prefix=/mingw LIBS="-lbz2 -ljpeg -lws2_32 -liconv"
Once Makefile is generated, change line 233 to read:
DEFS = -DHAVE_CONFIG_H -DBGDWIN32
Also fix gd.h near line 25:--- ./gd.h Sat Oct 30 12:54:58 2004
+++ ./gd.h Sun Jan 05 17:56:09 2006
@@ -24,7 +24,7 @@
#endif /* WIN32 */
#ifdef NONDLL
-#define BGD_DECLARE(rt) extern rt
+#define BGD_DECLARE(rt) extern rt _stdcall
#else
#ifdef BGDWIN32
#define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall
Then, build and install gdlib:make install
To create a DLL file called libgd-2.dll, run the following commands:
mkdir /tmp/gdlib
cd /tmp/gdlib
ar x /mingw/lib/libgd.a
gcc -shared -o /mingw/bin/libgd-2.dll -Wl,--out-implib,libgd.dll.a *.o -L/mingw/lib -lz -lbz2 -ljpeg -lpng -liconv -lfreetype - wget
Build wget as shown in this post. If you don't want to compile wget yourself, get the executable (wget.exe) somewhere, and put it in the same folder as mlnet.exe later. - regex and libmagic
Download regex-0.12.tar.gz and compile regex as required by libmagic.
gcc -DSTDC_HEADERS -DHAVE_STRING_H=1 -I. -c regex.c
ar ru libregex.a regex.o
cp -iv libregex.a /mingw/lib
cp -iv libregex.a /mingw/lib/libgnurx.a
cp -iv regex.h /mingw/includeGet the source tarball of open-source file command. Configure as follows:
./configure --build=i686-w64-mingw32 --prefix=/mingw
Open config.h and add the following lines:
#define WIN32 1
#define MAGIC "magic"Then compile:
make && make install
- OCaml
You need flexdll (flexdll-0.27.zip) to build OCaml. Extract it to /mingw/bin. Then, download the latest OCaml source (3.12.1). Patch ocaml with this Unicode patch.tar xzvf ocaml-3.12.1.tar.gz
cd ocaml-3.12.1
patch -p1 -l < ../ocaml-3.12.1-unicode.patchIn the
config
subfolder, copy Makefile.mingw to Makefile.cp config/m-nt.h config/m.h
cp config/s-nt.h config/s.h
cp config/Makefile.mingw config/Makefile
Begin compiling OCaml.make -f Makefile.nt world
make -f Makefile.nt opt
make -f Makefile.nt opt.opt
make -f Makefile.nt install
Set up OCaml environment variables:export CAMLLIB=/mingw/lib
export OCAMLLIB=/mingw/lib
export CAMLP4LIB=/mingw/lib/camlp4 - Build MLDonkey
Get the MLDonkey source, then unpack and configure it.tar xjvf mldonkey-3.1.0.tar.bz2
cd mldonkey-3.1.0
./configure --build=i686-w64-mingw32 --prefix=/mingw --disable-fasttrackTo link with the static GD library, append
-DNONDLL
to the CPPFLAG line of config/Makefile.configCPPFLAGS=-I/mingw/include -DNONDLL
Start compilation.export OCAML_SRC=~/ocaml-3.12.1
cp -iv /mingw/lib/stublibs/dllunix.dll .
make depend
make mlnet.static
strip mlnet.static
mv mlnet.static mlnet.exe
If the final linking stage fails, here is the command I used to produce mlnet.exe:g++ -g0 -O3 -o mlnet.exe -Wl,--subsystem,windows -L/lib/gcc/i686-w64-mingw32/4.5.3 -L/mingw/lib /tmp/camlstartup00193d.s build/flexdll_mingw.o /mingw/lib/std_exit.o src/daemon/common/commonMain.o build/driver.a build/core.a build/client.a build/common.a build/magic.a build/bitstring.a build/cdk.a build/extlib.a /mingw/lib/nums.a /mingw/lib/str.a /mingw/lib/unix.a /mingw/lib/bigarray.a /mingw/lib/stdlib.a src/utils/cdk/gdstubs.o src/networks/direct_connect/che3_c.o src/utils/lib/CryptoPP.o src/utils/lib/CryptoPP_stubs.o src/utils/net/upnp_stubs.o src/daemon/common/commonHasher_c.o src/utils/lib/magiclib_stub.o src/utils/bitstring/bitstring_c.o src/utils/cdk/zlibstubs.o src/utils/cdk/heap_c.o src/config/mingw/os_stubs_c.o src/utils/lib/fst_hash.o src/utils/lib/md4_comp.o src/utils/lib/md4_c.o src/utils/lib/charsetstubs.o src/utils/lib/md5_c.o src/utils/lib/sha1_c.o src/utils/lib/tiger.o src/utils/lib/stubs_c.o -lnums -lcamlstr -lunix -lbigarray -lgdi32 -luser32 -ladvapi32 -limm32 -lshell32 -lole32 resfile.o -lpthread -lmagic -lgd -ljpeg -lfreetype -lpng -lz -lbz2 -lws2_32 -lshlwapi /mingw/lib/libasmrun.a /mingw/lib/libcharset.dll.a /mingw/lib/libiconv.dll.a
Optonally, compress the executable with upx.upx --best --strip-relocs=0 mlnet.exe
Open the file
C:\Cygwin\etc\fstab
in a text editor and append the following line./usr/i686-w64-mingw32/sys-root/mingw /mingw none bind
Set the HOME variable.
Start the Cygwin terminal and type the following commands to set up Cygwin for Windows compilation.
cp /usr/bin/i686-w64-mingw32-g++.exe /usr/i686-w64-mingw32/bin/g++.exe
cp /usr/bin/i686-w64-mingw32-gcc.exe /usr/i686-w64-mingw32/bin/gcc.exe
cp /usr/bin/i686-w64-mingw32-cpp.exe /usr/i686-w64-mingw32/bin/cpp.exe
export PATH=/mingw/bin:/usr/i686-w64-mingw32/bin:/usr/local/bin:/usr/bin:/usr/lib/gcc/i686-w64-mingw32/4.5.3
export CC=/usr/bin/i686-w64-mingw32-gcc.exe
export PKG_CONFIG_PATH=/mingw/lib/pkgconfig
Here's my mldonkey builds.