Difference between revisions of "How to build VCMI (Linux)"

From VCMI Project Wiki
Jump to: navigation, search
(link to Git repo (instead of SVN))
(Replaced content with "{{Template:MovedToWebpage|https://vcmi.eu/developers/Building_Linux/}}")
 
(31 intermediate revisions by 10 users not shown)
Line 1: Line 1:
= Compiling VCMI =
+
{{Template:MovedToWebpage|https://vcmi.eu/developers/Building_Linux/}}
Supported C++ compilers for UNIX-like systems: GCC 4.6+, Clang 3.1+
 
 
 
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
 
 
 
= Setting up a development environment using QtCreator =
 
 
 
QtCreator is the recommended IDE for VCMI development on linux distros. (It may be used on other operating systems as well) It has the following advantages compared to other IDEs:
 
* Almost no manual configuration when used with CMake (Project configuration is read from CMake text files)
 
* Fast parser/indexer, stable
 
* Can use several compiler toolchains: GCC, Visual Studio, Clang
 
* Doesn't pollute SVN with project files
 
 
 
You can download QtCreator from here: http://qt-project.org/downloads#qt-creator
 
 
 
== Configuration ==
 
To open the project you have to click File -> Open file or project... -> Select /trunk/src/CMakeLists.txt.
 
 
 
 
 
For the first time and for every CMake project configuration change you have to execute CMake. This step can be done when opening the project for the first time or alternatively via the left bar -> Projects -> Build Settings -> Execute CMake. You have to specify CMake arguments and the build dir. CMake arguments can be the following:
 
<pre>-DCMAKE_BUILD_TYPE=Debug</pre>
 
The build dir should be set to something like /trunk/build for the debug build and /trunk/buildrel for the release build.
 
For cleaning the build dir a command like "make clean" may be not enough. Better way is to delete the build dir, re-create it and re-execute CMake. Steps for cleaning can be configured in the Projects tab as well.
 
 
 
== Debugging ==
 
There is a problem with QtCreator when debugging both vcmiclient and vcmiserver. If you debug the vcmiclient, start a game, attach the vcmiserver process to the gdb debugger(Debug > Start Debugging > Attach to Running External Application...) then breakpoints which are set for vcmiserver will be ignored. This looks like a bug, in any case it's not intuitively. Two workarounds are available luckily:
 
 
 
1) Run vcmiclient (no debug mode), then attach server process to the debugger
 
 
 
2) Open two instances of QtCreator and debug vcmiserver and vcmiclient separately(it works!)
 
 
 
= 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
 

Latest revision as of 16:06, 16 July 2024

Logo256.png    Page moved to VCMI-Homepage