|
|
(24 intermediate revisions by 9 users not shown) |
Line 1: |
Line 1: |
− | = Compiling VCMI =
| + | {{Template:MovedToWebpage|https://vcmi.eu/developers/Building_Linux/}} |
− | * Current baseline requirement for building is Ubuntu 14.04
| |
− | * Supported C++ compilers for UNIX-like systems are GCC 4.8+ and Clang 3.4+
| |
− | | |
− | Older distributions and compilers might work, but they aren't tested by [https://travis-ci.org/vcmi/vcmi/ Travis CI]
| |
− | | |
− | There is a guide for compiling and running VCMI located in the repository root directory: [https://github.com/vcmi/vcmi/blob/develop/README.linux README.linux]
| |
− | | |
− | '''Set automatically soft-links bash script'''
| |
− | | |
− | The last step in the above-mentioned compiling guide requires to create soft-links for convenient debugging and development in general. There is a bash script which does this step automatically for you. You have to enter the build path, specify the source path and select the usual library folder of the operating system. Then the script takes the work to create all those symbolic links. This is comfortable if you're working on different source folders(trunk, tag, branch) or build types(debug, release) and you want to switch from one build to the other. The link to the script is here: http://download.vcmi.eu/setBuildLinks
| |
− | | |
− | = Installing dependencies =
| |
− | | |
− | == Prerequisites ==
| |
− | | |
− | To compile, the following packages (and their development counterparts) are needed to build:
| |
− | * CMake 2.8.12 or newer
| |
− | * SDL2 with devel packages: mixer, image, ttf
| |
− | * zlib and zlib-devel
| |
− | * Optional of launcher: Qt 5, widget and network modules
| |
− | * FFmpeg libraries: libavformat and libswscale. Their name could be libavformat-devel and libswscale-devel, or ffmpeg-libs-devel or similar names.
| |
− | * Boost C++ libraries v1.48+: program-options, filesystem, system, thread, locale
| |
− | | |
− | == On Debian-based systems (e.g. Ubuntu) ==
| |
− | | |
− | <pre>
| |
− | sudo apt-get install cmake g++ libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev zlib1g-dev libavformat-dev libswscale-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev qtbase5-dev
| |
− | </pre>
| |
− | | |
− | Alternatively if you have VCMI installed from repository or PPA you can use:
| |
− | <pre>
| |
− | sudo apt-get build-dep vcmi
| |
− | </pre>
| |
− | | |
− | == On RPM-based distributions (e.g. Fedora) ==
| |
− | | |
− | <pre>
| |
− | sudo yum install cmake gcc-c++ SDL2-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel boost boost-devel boost-filesystem boost-system boost-thread boost-program-options boost-locale zlib-devel ffmpeg-devel ffmpeg-libs qt5-qtbase-devel
| |
− | </pre>
| |
− | | |
− | == On Arch-based distributions ==
| |
− | On Arch-based distributions, there is a development package available for VCMI on the AUR.
| |
− | | |
− | It can be found at: https://aur.archlinux.org/packages/vcmi-git/
| |
− | | |
− | Information about building packages from the Arch User Repository (AUR) can be found at the Arch wiki.
| |
− | | |
− | = Getting the sources =
| |
− | | |
− | VCMI is still in development. We recommend the following initial directory structure:
| |
− | <pre>
| |
− | .
| |
− | ├── vcmi -> contains sources and is under git control
| |
− | └── build -> contains build output, makefiles, object files,...
| |
− | </pre>
| |
− | | |
− | You can get latest sources with:
| |
− | <pre>
| |
− | git clone -b develop --depth 1 --recursive https://github.com/vcmi/vcmi.git
| |
− | </pre>
| |
− | | |
− | = Compilation =
| |
− | | |
− | == Configuring Makefiles ==
| |
− | <pre>
| |
− | mkdir build && cd build
| |
− | cmake ../vcmi
| |
− | | |
− | # Additional options that you may want to use:
| |
− | ## To enable debugging:
| |
− | cmake ../vcmi -DCMAKE_BUILD_TYPE=Debug
| |
− | </pre>
| |
− | '''Notice''':
| |
− | The ../vcmi/ is not a typo, it will place makefile scripts into the build dir as the build dir is your working dir when calling CMake.
| |
− | | |
− | == Trigger build ==
| |
− | <pre>
| |
− | cmake --build . -- -j2
| |
− | # -j2 = compile with 2 threads, you can specify any value
| |
− | </pre>
| |
− | That will generate vcmiclient, vcmiserver, vcmilauncher as well as 4 .so libraries in '''build/bin/''' directory.
| |
− | | |
− | = Package building =
| |
− | | |
− | == RPM package ==
| |
− | | |
− | The first step is to prepare a RPM build environment. On Fedora systems you can follow this guide: http://fedoraproject.org/wiki/How_to_create_an_RPM_package#SPEC_file_overview
| |
− | | |
− | 1. Download the file rpm/vcmi.spec from any tagged VCMI release for which you wish to build a RPM package via the SVN Browser trac at this URL for example(which is for VCMI 0.9): http://sourceforge.net/apps/trac/vcmi/browser/tags/0.9/rpm/vcmi.spec
| |
− | | |
− | 2. Copy the file to ~/rpmbuild/SPECS
| |
− | | |
− | 3. Follow instructions in the vcmi.spec. You have to export the corresponding SVN tag, compress it to a g-zipped archive and copy it to ~/rpmbuild/SOURCES. Instructions are written as comments and you can copy/paste commands into terminal.
| |
− | | |
− | 4. Go to ~/rpmbuild/SPECS and open terminal in this folder and type: <pre>rpmbuild -ba vcmi.spec (this will build rpm and source rpm)</pre>
| |
− | | |
− | 5. Generated RPM is in folder ~/rpmbuild/RPMS
| |
− | | |
− | If you want to package the generated RPM above for different processor architectures and operating systems you can use the tool mock. Moreover, it is necessary to install mock-rpmfusion_free due to the packages ffmpeg-devel and ffmpeg-libs which aren't available in the standard RPM repositories(at least for Fedora). Go to ~/rpmbuild/SRPMS in terminal and type:
| |
− | <pre>mock -r fedora-17-i386-rpmfusion_free path_to_source_RPM
| |
− | mock -r fedora-17-x86_64-rpmfusion_free path_to_source_RPM</pre>
| |
− | | |
− | Available root environments and their names are listed in /etc/mock.
| |
− | == Debian/Ubuntu ==
| |
− | 1. Install debhelper and devscripts packages
| |
− | | |
− | 2. Run dpkg-buildpackage command from vcmi source directory
| |
− | <pre>
| |
− | sudo apt-get install debhelper devscripts
| |
− | cd /path/to/source
| |
− | dpkg-buildpackage
| |
− | </pre>
| |
− | To generate packages for different architectures see "-a" flag of dpkg-buildpackage command
| |
− | | |
− | == Documentation ==
| |
− | | |
− | To compile using Doxygen, the UseDoxygen CMake module must be installed. It can be fetched from: http://tobias.rautenkranz.ch/cmake/doxygen/
| |
− | | |
− | Once UseDoxygen is installed, run:
| |
− | <pre>
| |
− | cmake .
| |
− | make doc
| |
− | </pre>
| |
− | | |
− | The built documentation will be available from ./doc
| |