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

From VCMI Project Wiki
Jump to: navigation, search
(Configure debug/run applications)
Line 1: Line 1:
= Compile, build and run VCMI =
+
= Compiling VCMI =
There is a guide for this located in the SVN trunk root directory: [https://vcmi.svn.sourceforge.net/svnroot/vcmi/trunk/README.linux README.linux]
+
There is a guide for compiling and running VCMI located in the SVN trunk root directory: [https://vcmi.svn.sourceforge.net/svnroot/vcmi/trunk/README.linux README.linux]
  
= How to set up a development environment using Eclipse CDT =
+
= Setting up a development environment using Eclipse CDT =
 
In order to do that you should followed the guide above first.
 
In order to do that you should followed the guide above first.
  
Line 43: Line 43:
 
</ol>
 
</ol>
  
== Set up a VCMI project ==
+
== Setup a VCMI project ==
  
=== Create eclipse project ===
+
=== Create project ===
 
# File -> New Project... -> C/C++ -> C++ Project -> Next
 
# File -> New Project... -> C/C++ -> C++ Project -> Next
 
# Type in a project name e.g. vcmi_animRewrite for the branch animRewrite, vcmi_trunk for the trunk, vcmi_0_88 for the tag 0.88
 
# Type in a project name e.g. vcmi_animRewrite for the branch animRewrite, vcmi_trunk for the trunk, vcmi_0_88 for the tag 0.88
Line 74: Line 74:
 
# Arguments may the following : <code class="inline">--datadir=/usr/local/share/games --bindir=/usr/local/games --libdir=/usr/local/lib64/games.</code> The /vcmi folder at the end of datadir and libdir is not missing. It will be added automatically by the configure script.
 
# Arguments may the following : <code class="inline">--datadir=/usr/local/share/games --bindir=/usr/local/games --libdir=/usr/local/lib64/games.</code> The /vcmi folder at the end of datadir and libdir is not missing. It will be added automatically by the configure script.
 
# Save configuration with Apply and Close.
 
# Save configuration with Apply and Close.
 +
 +
That way you don't need to run the ./configure script via the terminal. It can be executed within eclipse.
  
 
=== Configure make targets ===
 
=== Configure make targets ===
Line 81: Line 83:
 
# If you want to build the /client project only then you have to select the client folder and click on New Make Target
 
# If you want to build the /client project only then you have to select the client folder and click on New Make Target
 
# Target name: client, Make Target: Empty. OK.
 
# Target name: client, Make Target: Empty. OK.
 +
 +
This is needed to compile VCMI within eclipse. This has to be done manually, auto build is turned off.
  
 
=== Configure debug/run applications ===
 
=== Configure debug/run applications ===
 
# Go to Run -> Debug/Run configurations... -> Add new launch configuration(C++ application) -> Choose vcmiclient via Search project...
 
# Go to Run -> Debug/Run configurations... -> Add new launch configuration(C++ application) -> Choose vcmiclient via Search project...
 
# sudo vi /etc/ld.so.conf.d/vcmi-86_64.conf. Add this line: /usr/local/lib64/games/vcmi. This is needed because VCMI is not installed and to find shared libraries.
 
# sudo vi /etc/ld.so.conf.d/vcmi-86_64.conf. Add this line: /usr/local/lib64/games/vcmi. This is needed because VCMI is not installed and to find shared libraries.
 +
 +
With this configuration you can start and debug VCMI within eclipse.

Revision as of 15:29, 6 April 2012

Compiling VCMI

There is a guide for compiling and running VCMI located in the SVN trunk root directory: README.linux

Setting up a development environment using Eclipse CDT

In order to do that you should followed the guide above first.

Installing Eclipse

If you have installed Eclipse already, then you can skip this section.

  1. Eclipse offers a wide range of supported programming languages. The classic package only supports Java. It can be extended to support languages like C++, PHP, JavaScript, ActionScript,... via the "Install new software..."-dialog within Eclipse. Therefore you have one programming environment this means one program which provides many languages. That's the way described here. As a starting point download Eclipse Classic first. It can be obtained from here Eclipse downloads.
  2. Unpack the downloaded package.
    tar xzf eclipse.tar.gz
  3. Move it to the /opt directory which is used for additional mostly not-UNIX-like programs in matters of the directory structure.
    sudo mv eclipse /opt
  4. Adjust file access rights.
    cd /opt
    sudo chown -R root:root eclipse
    sudo chmod -R +r eclipse
    sudo chmod +x `sudo find eclipse -type d`
  5. Make eclipse more accessible.
    sudo touch /usr/bin/eclipse
    sudo chmod 755 /usr/bin/eclipse
    sudoedit /usr/bin/eclipse
    Enter these few lines in the editor, save the file and close the editor.
    #!/bin/sh
    

    export ECLIPSE_HOME="/opt/eclipse"

    $ECLIPSE_HOME/eclipse $*
  6. If you're using GNOME as the window manager then you may do the following steps. It's default on Fedora. That way you can start eclipse via the actvities window or the programs tab.
    sudoedit /usr/share/applications/eclipse.desktop

    Enter the following lines in the editor:

    [Desktop Entry]
    Encoding=UTF-8
    Name=Eclipse
    Comment=Eclipse IDE
    Exec=eclipse
    Icon=/opt/eclipse/icon.xpm
    Terminal=false
    Type=Application
    Categories=GNOME;Application;Development;
    StartupNotify=true 
  7. Clean eclipse.
    /opt/eclipse/eclipse -clean
  8. Start eclipse. Adjust workspace directory to sth. like: ~/Eclipse
  9. Go to: Help -> Install new software...
  10. Click on Add... and enter the Location http://download.eclipse.org/releases/indigo and Name Indigo. Make sure that you adjust the Location and Name to the used eclipse version.
  11. Type in Work with the name of the recently added repository. Then select the package Programming Languages -> C/C++ Development Tools and install it. This will install Eclipse CDT.

Setup a VCMI project

Create project

  1. File -> New Project... -> C/C++ -> C++ Project -> Next
  2. Type in a project name e.g. vcmi_animRewrite for the branch animRewrite, vcmi_trunk for the trunk, vcmi_0_88 for the tag 0.88
  3. Choose Makefile project -> Empty project -> Toolchain -> Linux GCC -> Finish
  4. Right click on project -> Properties. This will open the project properties where you can configure the sources folder, include paths,...

Add the bolded include paths as you can see them in the picture.

Eclipse Include Path.jpg

You have to click on Link Folder... and then Link to folder in the filesystem. Select the /src folder and the /build folder of one SVN project. If you link the /build folder then you can execute make targets.

Eclipse SourcePaths.jpg

Add the bolded symbols as you can see them in the picture. This one is missing add this as well: __GXX_EXPERIMENTAL_CXX0X__ That symbols are for the Eclipse CDT parser only.

Eclipse Symbols.jpg

You'll recognize that there are some errors in some source files. That's because the Eclipse parser can't understand every C++ language feature especially c++11. This doesn't mean that they are real errors. BOOST_FOREACH errors are fixed with the appropriate macro stated above in the picture. The parser has problems with std::make_pair perhaps this will be fixed in a later release of CDT as this error message appears often. We recommend to leave error, warning reporting turned on as you can directly see what is likely to be a problem for the GCC compiler.


Configure external program configure

  1. Go to Run -> External Tools -> External Tools Configuration...
  2. Add new launch configuration(Program) -> Choose the configure script as the location via the Browser Workspace Button
  3. Working directory is the /build folder
  4. Arguments may the following : --datadir=/usr/local/share/games --bindir=/usr/local/games --libdir=/usr/local/lib64/games. The /vcmi folder at the end of datadir and libdir is not missing. It will be added automatically by the configure script.
  5. Save configuration with Apply and Close.

That way you don't need to run the ./configure script via the terminal. It can be executed within eclipse.

Configure make targets

  1. Go to tab Make. If it's not open then: Window -> Show View -> Make target view
  2. Open the linked /build folder and click on New Make Target (Make sure you clicked the button while the root /build folder was selected)
  3. Target name: all, Make Target: Empty. OK.
  4. If you want to build the /client project only then you have to select the client folder and click on New Make Target
  5. Target name: client, Make Target: Empty. OK.

This is needed to compile VCMI within eclipse. This has to be done manually, auto build is turned off.

Configure debug/run applications

  1. Go to Run -> Debug/Run configurations... -> Add new launch configuration(C++ application) -> Choose vcmiclient via Search project...
  2. sudo vi /etc/ld.so.conf.d/vcmi-86_64.conf. Add this line: /usr/local/lib64/games/vcmi. This is needed because VCMI is not installed and to find shared libraries.

With this configuration you can start and debug VCMI within eclipse.