Compiling Mudlet

From Mudlet
Revision as of 02:06, 7 February 2015 by Vadi (talk | contribs) (Added OSX instructions)
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.

Note Note: Mudlet uses C++11 features now. Please use the latest versions of GCC (4.9.1) and Clang (3.5), if possible.

Compiling on Ubuntu

1. Install Git

sudo apt-get install git

2. Get Mudlet source

git clone https://github.com/Mudlet/Mudlet.git mudlet

3. Setup your environment

CI/travis.linux.before_install.sh
CI/travis.linux.install.sh

4. Go to the mudlet src folder

cd mudlet/src

5. Run the following commands

qmake
make -j 2
./mudlet

6. Enjoy

Compiling on OS X

1. Install prerequisites

Install XCode, command line tools for XCode, and HomeBrew.

Once homebrew is installed, do:

 brew doctor
 brew update
 brew install git


2. Get Mudlet source

git clone https://github.com/Mudlet/Mudlet.git mudlet

3. Setup your environment

cd mudlet
CI/travis.osx.before_install.sh
CI/travis.osx.install.sh

4. Go to the mudlet src folder

cd src

5. Run the following commands

qmake
make -j 2

6. Enjoy

Mudlet.app is now available in Finder for launching.

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 libquazip-dev


2. Grab latest Mudlet source.

$ cd ~ && mkdir projects && cd projects && git clone https://github.com/Mudlet/Mudlet.git


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.

$ \curl -sS http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-linux-x86-5.3.1.run
$ chmod +x qt-opensource* && ./qt-opensource*


5. Fix issues.

$ sudo ln -s /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h


6. Build Mudlet.

$ cd ..
$ /home/<username>/Qt5.3.1/5.3/gcc/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.

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.

Outdated compiling instructions

Instructions below need to be updated.

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.