Difference between revisions of "Compiling Mudlet"

From Mudlet
Jump to navigation Jump to search
Line 321: Line 321:
 
Copy the following dll's into the release directory:
 
Copy the following dll's into the release directory:
  
  cd release/
+
  cd debug/
 
  cp /c/Qt/5.6/mingw49_32/bin/icudt54.dll .
 
  cp /c/Qt/5.6/mingw49_32/bin/icudt54.dll .
 
  cp /c/Qt/5.6/mingw49_32/bin/icuin54.dll .
 
  cp /c/Qt/5.6/mingw49_32/bin/icuin54.dll .

Revision as of 07:35, 23 February 2017

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 by building on a Ubuntu 12.04 (Precise Pangolin) LTS Linux and a MacOS 10.11 platforms. This means that every push to the Git repository is test compiled on both Ubuntu and Mac OSX but not Microsoft Windows (yet).

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

Compiling on Ubuntu 12.04

1. Install Git

 sudo apt-get install git

2. Get Mudlet source

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

3. Go to the parent of the mudlet "src" folder and create (if necessary) a build subdirectory

(This is so that we can build out of source which keeps the source code clean!}

 cd mudlet
 mkdir build

4. Setup your environment

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

5 Move to the build location

 cd build

6. Run the following commands, depending on which build system you want to use (qmake IS recommended for Linux and Mac platforms)

EITHER:

 qmake ../src/src.pro

OR:

 cmake ..

THEN:

 make -j 2

if you have more than one processor core you can increase the number after -j to one more than the number of cores you would like to devote to building the application to speed things up.

7. Start the application you have just compiled - enjoy

 ./mudlet

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. Go to the parent of the mudlet "src" folder and create (if necessary) a build subdirectory (this is so that we can build out of source which keeps the source code clean}

 mkdir build

3. Setup your environment you only need the first three lines if your system cannot find the right Qt libraries or tools, the added directories might be different if you have installed them differently

 export PATH="/usr/local/opt/qt5/bin:$PATH"
 export LDFLAGS=" -L/usr/local/opt/qt5/lib ${LDFLAGS}"
 export CPPFLAGS=" -I/usr/local/opt/qt5/include ${CPPFLAGS}"
 CI/travis.osx.before_install.sh
 CI/travis.osx.install.sh

4. Go to the mudlet build folder

 cd build

5. Run the following commands, depending on which build system you want to use (qmake IS recommended for Linux and Mac platforms)

EITHER:

 qmake ../src/src.pro

OR:

 cmake ..

THEN:

 make -j `sysctl -n hw.ncpu`


6. Enjoy

The 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

Note Note: libzip has since reached the version 1.0 milestone - and it is possible that we will move forward to use later version library calls - this version is, I think the minimum version that is usable with the current Mudlet code which may be an issue for some earlier Debian distributions (7.x, "Wheezy" at least only ships a 0.10.x version). --slysven 19:41, 15 January 2017 (EST)


4. Download and install QT development package.

$ \curl -sS http://download.qt.io/official_releases/qt/5.6/5.6.2/qt-opensource-linux-x64-5.6.2.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 10

1.Download & Install the Prerequisites

Qt: 
 http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe
Run the installer and de-select everything and just select:
 Qt->Qt 5.6->MinGW 4.9.2 (32 bit)
 Qt->Qt 5.6->Source components
In this tutorial, it is installed in C:\Qt\ (so you will have C:\Qt\5.x)
7Zip:
 http://www.7-zip.org/a/7z1602-x64.msi
Notepad++: 
 https://notepad-plus-plus.org/download (at the last check it was at version 7.3)
Recommended if you don't have a good source editor installed already (it is release under a GPL License).
Mingw-builds:
 https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-posix/dwarf/x32-4.8.1-release-posix-dwarf-rev5.7z/download
extract this to C:\mingw32
Latest msys from:
 http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
put the msys folder in C:\mingw32, so you get C:\mingw32\msys
CMake:
 http://www.cmake.org/files/v3.0/cmake-3.0.0-win32-x86.exe
Python:
 https://www.python.org/ftp/python/2.7.11/python-2.7.11.msi


2.Download libraries in MSYS

Open MSYS (click msys.bat in the C:\mingw32\msys folder), where you'll be in a home directory. Copy the lines below and right-click on the terminal to paste them:

mkdir src
cd src
wget --no-check-certificate --output-document hunspell-1.4.1.tar.gz https://github.com/hunspell/hunspell/archive/v1.4.1.tar.gz
wget http://www.lua.org/ftp/lua-5.1.5.tar.gz
wget --no-check-certificate https://sourceforge.net/projects/pcre/files/pcre/8.38/pcre-8.38.tar.gz/download
wget http://zlib.net/zlib-1.2.11.tar.gz
wget http://www.sqlite.org/2013/sqlite-autoconf-3071700.tar.gz
wget --no-check-certificate https://launchpad.net/ubuntu/+archive/primary/+files/libzip_0.11.2.orig.tar.gz
wget --no-check-certificate --output-document yajl-2.0.1.tar.gz https://github.com/lloyd/yajl/tarball/2.0.1
wget --no-check-certificate https://sourceforge.net/projects/zziplib/files/zziplib13/0.13.62/zziplib-0.13.62.tar.bz2/download

A folder will get created in C:\mingw32\msys\home\your_name\src with all the files.

Extract all libraries with:

for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done
for a in `ls -1 *.tar.bz2`; do tar xvfj $a; done

Boost:

wget --no-check-certificate https://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz/download
/c/Program\ Files/7-Zip/7z e boost_1_60_0.tar.gz && /c/Program\ Files/7-Zip/7z x boost_1_60_0.tar
cp -r boost_1_60_0/boost /c/mingw32/include

3.Compiling libraries

Environment Settings

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

C:\Python27
C:\mingw32\bin
C:\Program Files (x86)\CMake\bin
C:\Qt\5.6\mingw49_32\bin

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

MSYS Compilations

All of the following will be completed inside the msys command prompt.

cd into each respective directory:

Hunspell:

./configure --prefix=/c/mingw32 && make -j 2 && make install

YAJL: Edit CMakeLists.txt in the base dir of YAJL, and make the following changes to remove all the windows specific compiler settings:

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")

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

change TO_LIB= liblua.a to TO_LIB= liblua.a lua51.dll

make mingw
make install

PCRE:

./configure --prefix=/c/mingw32 && make -j 2 && make install

Sqlite:

./configure --prefix=/c/mingw32 && make -j 2 && 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 -j 2 && make install
cp lib/zipconf.h /c/mingw32/include

ZZIPlib:

powershell -Command "(gc configure) -replace 'uname -msr', 'uname -ms' | Out-File -encoding ASCII configure"
configure --disable-mmap --prefix=c:/mingw32/ && make -j 2 && make install

3.Downloading Mudlet Sources

Getting Mudlet

From within msys:

cd ~/src
git clone https://github.com/Mudlet/Mudlet.git
cd Mudlet/src
git checkout release_30 

Building Mudlet from terminal

cd ~/src/Mudlet/src
qmake CONFIG+=debug
make -j 2

Building Mudlet from QtCreator

Open src.pro (within Mudlet2/src) in Qt Creator, disable shadow builds for both release and debug. Change build type to debug (bottom-left) and compile.

4.Copy Needed DLLs

Copy the following dll's into the release directory:

cd debug/
cp /c/Qt/5.6/mingw49_32/bin/icudt54.dll .
cp /c/Qt/5.6/mingw49_32/bin/icuin54.dll .
cp /c/Qt/5.6/mingw49_32/bin/icuuc54.dll .
cp /c/Qt/5.6/mingw49_32/bin/Qt5Core.dll .
cp /c/Qt/5.6/mingw49_32/bin/Qt5Gui.dll .
cp /c/Qt/5.6/mingw49_32/bin/Qt5Network.dll .
cp /c/Qt/5.6/mingw49_32/bin/Qt5OpenGL.dll .
cp /c/Qt/5.6/mingw49_32/bin/Qt5Widgets.dll .
cp /c/Qt/5.6/mingw49_32/bin/Qt5Multimedia.dll .
cp /c/Qt/5.6/mingw49_32/bin/libgcc_s_dw2-1.dll .
cp /c/Qt/5.6/mingw49_32/bin/libstdc++-6.dll .
cp /c/Qt/5.6/mingw49_32/bin/libwinpthread-1.dll .
cp /c/mingw32/lib/libyajl.dll .
cp $HOME/src/lua-5.1.5/src/lua51.dll .
cp $HOME/src/lua-5.1.5/src/lua51.dll /c/mingw32/bin
cp /c/mingw32/bin/libzip-2.dll .
cp /c/mingw32/bin/libhunspell-1.4-0.dll .
cp /c/mingw32/bin/libpcre-1.dll .
cp /c/mingw32/bin/libsqlite3-0.dll .
cp /c/mingw32/bin/zlib1.dll .
cp -r ../mudlet-lua/ .
cp ../*.dic .
cp -r /c/Qt/5.6/mingw49_32/plugins/audio .
cp -r /c/Qt/5.6/mingw49_32/plugins/mediaservice .
cp -r /c/Qt/5.6/mingw49_32/plugins/platforms .


5.Setting up Lua libraries

At this point your Lua install will be bare-bones and lacking the Lua libraries Mudlet uses.

cd ~/src
wget --no-check-certificate http://keplerproject.github.io/luarocks/releases/luarocks-2.4.0-win32.zip
unzip luarocks-2.4.0-win32.zip

Switch to the Windows command line to install luarocks:

cd C:\mingw32\msys\home\%USERNAME%\src\luarocks-2.4.0-win32
install.bat /P C:\LuaRocks /MW

Wait for the installation to finish. Then:

cd \LuaRocks\lua\luarocks
powershell -Command "(gc cfg.lua) -replace 'mingw32-gcc', 'gcc' | Out-File -encoding ASCII cfg.lua"
cd \LuaRocks
luarocks install LuaFileSystem
luarocks install LuaSQL-SQLite3 SQLITE_INCDIR="c:\mingw32\include" SQLITE_LIBDIR="c:\mingw32\lib"
luarocks install lrexlib-pcre PCRE_LIBDIR="c:\mingw32\lib" PCRE_INCDIR="c:\mingw32\include"

Back in the msys command line:

cd ~/src
wget --no-check-certificate https://github.com/rjpcomputing/luazip/archive/master.zip
unzip master
cd luazip-master/
gcc -O2 -c -o src/luazip.o -IC:/mingw32/include/ src/luazip.c 
gcc -shared -o zip.dll src/luazip.o -Lc:\mingw32\lib -lzzip -lz c:/mingw32/bin/lua51.dll -lm
cp zip.dll ~/src/Mudlet/src/release
cp -r /c/mingw32/lib/lua/5.1/* ~/src/Mudlet/src/release



You're done! You can now launch mudlet by running mudlet.exe in the release/ folder, or from command line:

cd ~/src/Mudlet/src/release
./mudlet.exe