Compiling Mudlet

From Mudlet
Jump to navigation Jump to search

Contributing

Clang format can be used to automatically format code submissions. Go here for more information on Clang format: http://clang.llvm.org/docs/ClangFormat.html

Travis Integration

Mudlet is hosted on Github and uses Travis for continuous integration. This means that every push to the Git repository is compiled on both Ubuntu and Mac OSX.

Travis integration is defined in a .travis.yml file and in our case, it references shell scripts in the CI directory, which handle things like installing dependencies and building mudlet.

Note Note: Travis builds do not currently package mudlet, so not everything is automated.

Compiling

Note Note: Mudlet uses Qt 5.2 now. In cases where an earlier Qt version is mentioned, please use Qt 5.2.

Compiling on Ubuntu 12.10 / 13.04

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 libzip-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 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
libzip-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 on Debian 'Sid'

1. Install required packages from main repo.

$ sudo apt-get install build-essential lua5.1 liblua5.1-0-dev libpcre3-dev libboost-dev zlib1g-dbg zlib1g-dev libyajl2 \
libyajl-dev libyajl2-dbg libphonon-dev libhunspell-dev lua-filesystem zlib-bin libzzip-dev lua-rex-pcre lua-zip \
lua-sql-sqlite3 qt5-default git


2. Grab latest Mudlet source.

$ cd ~ && mkdir projects && cd projects && git clone git://git.code.sf.net/p/mudlet/code mudlet


3. Build latest libzip.

$ cd mudlet/src && wget http://www.nih.at/libzip/libzip-0.11.1.tar.gz
$ tar -xvzf libzip-0.11.1.tar.gz && cd libzip-0.11.1
$ ./configure && make && sudo make install


4. Download and install QT development package.

$ chmod +x qt-opensource* && ./qt-opensource*


5. Build Mudlet.

$ cd ..
$ ~/Qt5.3.1/bin/qmake
$ make

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.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;

Be sure to restart msys.bat after setting the above to pick up the new values.

'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, and make the following changes to 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")
And then compile:
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\mingw...(whatever the version is)\bin:
icudt5x.dll, icuin5x.dll, icuuc5x.dll, Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5OpenGL.dll, Qt5Widgets.dll
From mingw32\lib:
libyajl.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 from the windows command line
   (NOTE: The /P switch must be capitalized)
Edit C:\LuaRocks\2.x\lua\luarocks\cfg.lua, and change all instances of 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