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

From VCMI Project Wiki
Jump to: navigation, search
(Configure debug/run applications)
(Configure debug/run applications)
Line 88: Line 88:
 
VCMI won't start/debug if you don't set a specific environment variable due to shared libraries loading. Go to tab Environment -> New... Name = LD_LIBRARY_PATH Value = e.g. /usr/local/lib64/games/vcmi(where your shared libraries are located)
 
VCMI won't start/debug if you don't set a specific environment variable due to shared libraries loading. Go to tab Environment -> New... Name = LD_LIBRARY_PATH Value = e.g. /usr/local/lib64/games/vcmi(where your shared libraries are located)
  
Then go to Project -> Properties -> C/C++ Build -> Builder settings -> Change build location to sth. like project/build(where your makefiles are located)
+
Then go to Project -> Properties -> C/C++ Build -> Builder settings -> Change build location to sth. like project/build(where your makefiles are located). That way the project will be automatically built before launching/debugging.

Revision as of 13:55, 21 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 debug/run applications

Go to Run -> Debug/Run configurations...

Add new launch configuration(C++ application)

Choose vcmiclient via Search project...

Make sure that Use Workspace Settings is enabled

VCMI won't start/debug if you don't set a specific environment variable due to shared libraries loading. Go to tab Environment -> New... Name = LD_LIBRARY_PATH Value = e.g. /usr/local/lib64/games/vcmi(where your shared libraries are located)

Then go to Project -> Properties -> C/C++ Build -> Builder settings -> Change build location to sth. like project/build(where your makefiles are located). That way the project will be automatically built before launching/debugging.