Difference between revisions of "Compiling Mudlet"

From Mudlet
Jump to navigation Jump to search
(Compiling on Debian 7.1 ("Wheezy") - additional LUA dependences noted)
Line 210: Line 210:
 
== Compiling in Gentoo ==
 
== Compiling in Gentoo ==
 
An [https://github.com/toaster/gentoo-mudlet-overlay overlay is available] for compiling Mudlet on Gentoo.
 
An [https://github.com/toaster/gentoo-mudlet-overlay overlay is available] for compiling Mudlet on Gentoo.
 +
 +
== Compiling on Windows 7 ==
 +
 +
'''1.Download & Install the Prerequisites'''
 +
 +
Qt 5.1 (32 bit works fine for Mudlet):
 +
  http://download.qt-project.org/official_releases/online_installers/qt-windows-opensource-1.4.0-x86-online.exe
 +
In this tutorial, it is installed in C:\Qt\ (so you will have C:\Qt\5.1.0)
 +
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
 +
 +
 +
'''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
 +
 +
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
 +
Quazip:
 +
  http://sourceforge.net/projects/quazip/, put it into the 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'''
 +
 +
''''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
 +
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 
 +
 +
''''Windows Compilations''''
 +
 +
This is from the normal windows cmd line
 +
 +
QuaZip:
 +
Edit quazip\quazip.pro:
 +
INCLUDEPATH += "C:\mingw32\include"
 +
LIBS += -L"C:\mingw32\lib" \
 +
-lzlib1
 +
qmake.exe PREFIX=C:\mingw32\
 +
mingw32-make
 +
mingw32-make install
 +
 +
'''3.Downloading Mudlet Sources'''
 +
 +
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)
 +
edit src.pro
 +
add to win32:INCLUDEPATH
 +
    "c:\mingw32\include"
 +
add  to win32:LIBS:
 +
    "c:\mingw32\lib" \
 +
-lzlib1
 +
qmake.exe
 +
make
 +
 +
'''4.Copy Needed DLLs'''
 +
 +
copy the following dll's into the release directory:
 +
 +
From Qt\5.1.0\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
 +
luarocks install lrexlib-sqlite PCRE_LIBDIR="c:\mingw32\lib" PCRE_INCDIR="c:\mingw32\include"
 +
 +
Now copy all the dlls from LuaRocks/lib/lua/5.1 to the mudlet release directory

Revision as of 23:48, 31 July 2013

Compiling on Ubuntu 12.10

1. Install GIT

sudo apt-get install git

2. Installing the needed packages

sudo apt-get install build-essential qt4-dev-tools lua5.1 liblua5.1-0-dev libpcre3-dev libboost-dev zlib1g-dbg zlib1g-dev libyajl2 \
libyajl-dev libyajl2-dbg liblua5.1-rex-pcre0 liblua5.1-sql-sqlite3-2 libphonon-dev libhunspell-dev libzzip-dev liblua5.1-zip0 \
liblua5.1-filesystem0

3. get mudlet source

git clone git://git.code.sf.net/p/mudlet/code
{old location git://mudlet.git.sourceforge.net/gitroot/mudlet/mudlet no longer valid}

4. goto the mudlet src folder

cd mudlet/src

5.a edit src.pro like so (for 32bit):

replace the corresponding part near the beginning of the file with this:

LIBLUA = -llua5.1
!exists(/usr/lib/i386-linux-gnu/liblua5.1.a):LIBLUA = -llua

# automatically link to LuaJIT if it exists
exists(/usr/lib/i386-linux-gnu/libluajit-5.1.a):LIBLUA = -L/usr/lib/i386-linux-gnu/ -lluajit-5.1


5.b edit src.pro like so (for 64bit):

replace the corresponding part near the beginning of the file with this:

LIBLUA = -llua5.1
!exists(/usr/lib/x86_64-linux-gnu/liblua5.1.a):LIBLUA = -llua

# automatically link to LuaJIT if it exists
exists(/usr/lib/x86_64-linux-gnu/libluajit-5.1.a):LIBLUA = -L/usr/lib/x86_64-linux-gnu/ -lluajit-5.1

6. address the removal of yajl1 from the offical repos (thanks to Blackice89 for this info from the arch compile guide)

wget http://vrac.kadarniad.fr/lua_yajl2.c
for i in *.{cpp,h} ; do sed -i 's/#include <phonon>/#include <phonon\/MediaObject>\n#include <phonon\/AudioOutput>/' $i ; done
sed -i 's/lua_yajl1.c/lua_yajl2.c/' TLuaInterpreter.cpp
sed -i 's/-lhunspell/-lhunspell-1.3/' src.pro
sed -i 's/lua_yajl1.c/lua_yajl2.c/' src.pro
sed -i '/MOC_DIR.*/i QMAKE_MOC += -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED' src.pro
sed -i '/.*unix:LIBS.*/a -lz \\' src.pro

6. Alternative Step 6

Remove the downloaded yajl libraries:
 sudo apt-get remove libyajl2 libyajl-dev libyajl2-dbg
Download yajl from here:
 http://github.com/lloyd/yajl/tarball/1.0.12
in the directory it was extracted to, run:
configure (you may need to install ruby for this, sudo apt-get ruby for that)
make
sudo make install
edit src.pro again, and replace -lyajl with:
   -L/usr/local/lib/ \
   -lyajl \

7. run the following commands

qmake-qt4
make
./mudlet


8. enjoy

Compiling on Ubuntu 11.10

1. Install GIT

sudo apt-get install git

2. Installing the needed packages

sudo apt-get install build-essential qt4-dev-tools lua5.1 liblua5.1-0-dev libpcre3-dev libboost1.46-dev zlib1g-dbg zlib1g-dev libyajl1
libyajl-dev libyajl1-dbg liblua5.1-rex-pcre0 liblua5.1-sql-sqlite3-2 libphonon-dev libhunspell-dev libzzip-dev liblua5.1-zip0 
liblua5.1-filesystem0

3. get mudlet source

git clone git://git.code.sf.net/p/mudlet/code
{old location git://mudlet.git.sourceforge.net/gitroot/mudlet/mudlet no longer valid}

4. goto the mudlet src folder

cd mudlet/src

5.a edit src.pro like so (for 32bit):

replace the corresponding part near the beginning of the file with this:

LIBLUA = -llua5.1
!exists(/usr/lib/i386-linux-gnu/liblua5.1.a):LIBLUA = -llua

# automatically link to LuaJIT if it exists
exists(/usr/lib/i386-linux-gnu/libluajit-5.1.a):LIBLUA = -L/usr/lib/i386-linux-gnu/ -lluajit-5.1


5.b edit src.pro like so (for 64bit):

replace the corresponding part near the beginning of the file with this:

LIBLUA = -llua5.1
!exists(/usr/lib/x86_64-linux-gnu/liblua5.1.a):LIBLUA = -llua

# automatically link to LuaJIT if it exists
exists(/usr/lib/x86_64-linux-gnu/libluajit-5.1.a):LIBLUA = -L/usr/lib/x86_64-linux-gnu/ -lluajit-5.1

6. run the following commands

qmake-qt4
make
./mudlet


7. enjoy


Compiling on Debian 7.1 ("Wheezy")

1. Install GIT. In a terminal window type:

sudo apt-get install git


2. Install needed Debian packages. Only the development [-dev] ones are shown here, as this should also get the associated main packages auto-magically if not already present on the system:

sudo apt-get install "compiler packages & qt-sdk packages"
liblua5.1-0-dev libboost-dev libhunspell-dev libphonon-dev lua-zlib-dev
libzzip-dev libyajl-dev lua-rex-pcre lua-zip lua-filesystem lua-sql-sqlite3

N.B. "compiler packages & qt-sdk packages" could probably be "g++", "libstdc++6" and "qmake" to pull in the default GCC C++ compiler and associated libraries and qt Make system; "qt4-dev-tools" to pull in the development Qt libraries; "gdb" if you are planning on doing any debugging and "qtcreator" to provide a nice IDE to do it all in. The last four dependences are not required to compile the code but their absence will show up in error messages from the LUA subsystem as connection is made to a MUD and the session starts up, unlike other dependences only the main files seem to be required (it not being necessary to include the development [-dev] packages.)

3. Build and install non-Debian packages. Which presently is only the C++/Qt Zip library "quazip", download the latest version quazip-0.5.1.zip. After unzipping to a new directory of your choice add: "QMAKE_CXXFLAGS += -fpermissive" near the top of the "./qztest/qztest.pro" file to change errors to warnings on assigning some gzFile pointers to void ones in the test suite - this seems to be needed to get the whole thing to compile (though the test suite isn't necessary for compiling Mudlet purposes). After making that change in a terminal window run "qmake" on the quazip project file in the base of the quazip project directory tree to update the subdirectory project files. After building (with "make") in that base directory use "sudo make install" to install the newly constructed files in your system - this puts headers in /include and libraries in /lib of your file-system so some tweaking in the last couple of bits of this section could avoid the need to manually move the library and the three symbolic links from /lib to /usr/local/lib/ and the header files from /includes to /usr/local/includes/.

4. Get the Mudlet source. In a terminal window:

git clone git://git.code.sf.net/p/mudlet/code

5. Compile the Mudlet source. In that terminal window:

 qmake
 make

or if you've got qtcreator set up once you've opened the Mudlet project file which is "./src/src.pro" relative to wherever you had Git clone the code in the previous step, hit the "build src.pro" and go and grab a hot drink or whatever whilst the code is compiled...!

6. Run Mudlet, and Enjoy. From a terminal window run the mudlet executable, as it is relative to where you had Git clone the code to this will be the file:

./src/mudlet

Like other systems documented here, it may not be possible to do a "make install" to make this executable work for all users of the system on which it has just been built. At the point of writing the default Qt libraries provided for Debian "Wheezy" are version 4.8.2 which may not match the ones of the Qt-sdk recommended by the Mudlet makers. In the event of problems in that area you may be recommended to build that specific version of the libraries and recompile Mudlet with them - fortunately Qt-Creator does make the latter part relatively straightforward.

Compiling in ArchLinux

The best way to do this would be to use the PKGBUILD found here. You'll just download the PKGBUILD into a directory, run

makepkg
sudo pacman -U [name of the generated pkg file]

and you'll be done. For more info on what this does, visit this site. If you really want to compile it by hand, please note that it won't be as simple due to ArchLinux' aggressive update philosophy. The instructions provided here might be outdated due to said philosophy, so you will have to know how to use Google, and you'll need to be willing to read through C++ compilation errors. If you're still willing to go through this, then read on.

1. Install required packages

Mudlet has a bunch of dependencies that you'll need to compile the source. You can get an updated list of packages here, it's just a matter of figuring out what they're called in pacman. As for the lua dependencies, I recommend you get luarocks, and use it to install them. You'll also need git to download the source.

2. Get the source through Git

Run the following in a terminal to get the source:

git clone git://git.code.sf.net/p/mudlet/code
{old location git://mudlet.git.sourceforge.net/gitroot/mudlet/mudlet no longer valid}

it should download the source automatically.

3. Address yajl issue

There are two versions of yajl: 1 and 2. If you installed yajl via pacman, you probably have 2. If you do have two, then you'll have to download this file and add it into the src directory. If you do not want to do this, then download and install yajl1 from AUR.

3. Edit src.pro (to be improved)

Run the following in a terminal from the src directory:

for i in *.{cpp,h} ; do sed -i 's/#include <phonon>/#include <phonon\/MediaObject>\n#include <phonon\/AudioOutput>/' $i ; done
sed -i 's/lua_yajl1.c/lua_yajl2.c/' TLuaInterpreter.cpp
sed -i 's/-lhunspell/-lhunspell-1.3/' src.pro
sed -i 's/lua_yajl1.c/lua_yajl2.c/' src.pro
sed -i '/MOC_DIR.*/i QMAKE_MOC += -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED' src.pro
sed -i '/.*unix:LIBS.*/a -lz \\' src.pro
sed -i 's#QString path = \"mudlet-lua/lua/LuaGlobal.lua\";#QString path = \"/usr/local/share/mudlet/LuaGlobal.lua\";#' TLuaInterpreter.cpp

4. Compile the source

qmake
make

5. Run Mudlet

./mudlet

Compiling in Gentoo

An overlay is available for compiling Mudlet on Gentoo.

Compiling on Windows 7

1.Download & Install the Prerequisites

Qt 5.1 (32 bit works fine for Mudlet):
 http://download.qt-project.org/official_releases/online_installers/qt-windows-opensource-1.4.0-x86-online.exe
In this tutorial, it is installed in C:\Qt\ (so you will have C:\Qt\5.1.0)
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


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

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
Quazip:
 http://sourceforge.net/projects/quazip/, put it into the 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

'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
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  

'Windows Compilations'

This is from the normal windows cmd line

QuaZip:
Edit quazip\quazip.pro:
INCLUDEPATH += "C:\mingw32\include"
LIBS += -L"C:\mingw32\lib" \
	-lzlib1
qmake.exe PREFIX=C:\mingw32\
mingw32-make
mingw32-make install

3.Downloading Mudlet Sources

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)
edit src.pro
add to win32:INCLUDEPATH
   "c:\mingw32\include"
add  to win32:LIBS:
   "c:\mingw32\lib" \
	-lzlib1
qmake.exe
make

4.Copy Needed DLLs

copy the following dll's into the release directory:

From Qt\5.1.0\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
luarocks install lrexlib-sqlite PCRE_LIBDIR="c:\mingw32\lib" PCRE_INCDIR="c:\mingw32\include"

Now copy all the dlls from LuaRocks/lib/lua/5.1 to the mudlet release directory