Compiling Mudlet

From Mudlet
Revision as of 19:53, 9 July 2014 by Chris (talk | contribs)
Jump to navigation Jump to search

Compiling on Windows 7

1.Download & Install the Prerequisites

Qt 5.3.1
 http://download.qt-project.org/official_releases/online_installers/qt-opensource-windows-x86-1.6.0-4-online.exe
Run the installer and de-select everything and just select:
 Qt->Qt 5.3->MinGW 4.8.2 (32 bit)
 Qt->Qt 5.3->Source Components (if you intend to debug/etc)
In this tutorial, it is installed in C:\Qt\ (so you will have C:\Qt\5.x)
Mingw-builds:
 http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-posix/dwarf/
extract this to C:\mingw32
latest msys from:
 http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
put the msys folder in C:\mingw32
CMake:
 http://www.cmake.org/files/v3.0/cmake-3.0.0-win32-x86.exe


2.Download libraries in MSYS

Open MSYS(click msys.bat in the msys folder), where you'll be in a home directory. Now enter:

mkdir src
cd src
wget http://downloads.sourceforge.net/hunspell/hunspell-1.3.2.tar.gz
wget http://www.lua.org/ftp/lua-5.1.5.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget http://www.sqlite.org/2013/sqlite-autoconf-3071700.tar.gz
wget http://www.nih.at/libzip/libzip-0.11.2.tar.gz

You'll need to manually download and extract the contents of these files into your msys src folder as well. The path for msys src is C:\mingw32\msys\home\your_name\src\.

Boost:
 http://sourceforge.net/projects/boost/files/boost/1.45.0/boost_1_45_0.tar.gz/download, extract the "boost" folder to C:/mingw32/include/
Yajl:
 http://github.com/lloyd/yajl/tarball/2.0.1, put it into the msys src folder

Now untar/unzip everything into the src folder.

Syntax inside msys for untarring: tar -zxvf hunspell-1.3.2.tar.gz
and so on for the rest

3.Compiling libraries

'Environment Settings'

You want control over what compilers are being using so prefix your PATH with (in system environmental variables):

C:\mingw32\bin;C:\Program Files (x86)\CMake\bin;

'MSYS Compilations'

All these will be compiled inside the msys command prompt cd into each respective directory:

Hunspell:
./configure --prefix=/c/mingw32
You'll get an error in localname.c if you make right away, edit this file (intl/localename.c, comment out case SUBLANG_SINDHI_PAKISTAN:  return "sd_PK";)
make && make install
YAJL:
Edit CMakeLists.txt in the base dir of YAJL, remove all the windows specific compiler garbage:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") to SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
SET(linkFlags "/PDB:NONE /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF") to SET(linkFlags)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4255 /wd4130 /wd4100 /wd4711") to SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "/D DEBUG /Od /Z7") to SET(CMAKE_C_FLAGS_DEBUG "-g")
SET(CMAKE_C_FLAGS_RELEASE "/D NDEBUG /O2") to SET(CMAKE_C_FLAGS_RELEASE "-O2")
mkdir build
cd build
cmake -G "MSYS Makefiles" ..
make
cp yajl-2.0.1/lib/* /c/mingw32/lib/
cp -R yajl-2.0.1/include/* /c/mingw32/include/

Lua:
edit the Makefile, change INSTALL_TOP= /usr/local to INSTALL_TOP= /c/mingw32
make mingw
make install

PCRE:
./configure --prefix=/c/mingw32 && make && make install

Sqlite:
./configure --prefix=/c/mingw32 && make && make install
 
ZLib:
make -f win32/Makefile.gcc
export INCLUDE_PATH=/c/mingw32/include/
export LIBRARY_PATH=/c/mingw32/lib/
export BINARY_PATH=/c/mingw32/bin/
make -f win32/Makefile.gcc install
cp zlib1.dll /c/mingw32/bin
cp libz.dll.a /c/mingw32/lib
LibZip:
./configure --prefix=/c/mingw32 && make && make install
cp lib/zipconf.h /c/mingw32/include

3.Downloading Mudlet Sources

'Getting Mudlet' From within msys:

cd to wherever you want to put your sources. You can do this from something like C:\gits\

git clone https://github.com/Chris7/Mudlet2.git
cd Mudlet2/src (if using my github repo)
git checkout mudletDev
edit src.pro and add:
to Win32:LIBS:
change:
 -lzlib to -lzlib1
 -lhunspell to -lhunspell-1.3-0
 -lpcre to -lpcre-1
 -llibzip to -llibzip-2
add right above -llua51:
 -L"C:\\mingw32\\bin" \

'Building Mudlet from terminal'

Now we want to add Qt to our path. Prefix our path with:

C:\Qt\5.3\mingw482_32\bin

and reopen msys.bat

cd /c/gits/Mudlet2/src
qmake.exe
make

'Building Mudlet from QtCreator'

Open src.pro (within Mudlet2/src) in Qt Creator

4.Copy Needed DLLs

copy the following dll's into the release directory:

From Qt\5.x.x\mingw42_32\bin:
icudt51.dll, icuin51.dll, icuuc51.dll, Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5OpenGL.dll, Qt5Widgets.dll
copy mudlet-lua into the release directory

5.Setting up Lua libraries At this point your lua install will be bare-bones. You'll need to install lua packages:

Get the 32 bit of luarocks, install it with install.bat /p C:\LuaRocks /MW
edit C:\LuaRocks\2.0\lua\luarocks\cfg.lua, change mingw32-gcc to gcc
From windows command line:
go into C:\LuaRocks\2.0
luarocks install LuaFileSystem
luarocks install LuaZip
luarocks install LuaSQL-SQLite3 SQLITE_INCDIR="c:\mingw32\include"
luarocks install lrexlib-sqlite PCRE_LIBDIR="c:\mingw32\lib" PCRE_INCDIR="c:\mingw32\include"

Now copy the contents of from LuaRocks/lib/lua/5.1 to the mudlet release directory