Difference between revisions of "HowTo:Compile from SVN on Linux"

From VsWiki
Jump to: navigation, search
m (With CMake (recommended): add notes on enabling a more verbose build process)
m (With CMake (recommended): The correct path to the mesher_tool binary is ./build/objconv/mesh_tool, not ./build/mesh_tool/mesh_tool)
 
(One intermediate revision by one other user not shown)
Line 35: Line 35:
 
** '''libgtk2.0''' + '''libgtk2.0-devel'''
 
** '''libgtk2.0''' + '''libgtk2.0-devel'''
 
** '''libfreeimage3''' (vegastrike itself can compile without it, but mesher can't)
 
** '''libfreeimage3''' (vegastrike itself can compile without it, but mesher can't)
 +
** '''cmake''' (and '''cmake-curses-gui''' if you want to use more convenient ccmake)
  
 
On '''Debian''', this probably should do the trick in (copy and paste the into terminal):
 
On '''Debian''', this probably should do the trick in (copy and paste the into terminal):
Line 44: Line 45:
 
</pre>
 
</pre>
  
On '''XUbuntu 12.10''', this should do the trick (copy and paste into terminal):
+
On '''XUbuntu 12.10'''+, this should do the trick (copy and paste into terminal):
  
 
<pre>
 
<pre>
Line 61: Line 62:
 
     lib{X11,Xdmcp,xkbfile,Xmu,Xpm,Xres,XScrnSaver,Xtst,Xv,Xxf86misc}-devel
 
     lib{X11,Xdmcp,xkbfile,Xmu,Xpm,Xres,XScrnSaver,Xtst,Xv,Xxf86misc}-devel
 
</pre>
 
</pre>
 +
 +
Not strictly necessary, but to get as many used libraries as you can: x11proto-resource-dev libxkbfile-dev libxpm-dev libxres-dev libxv-dev libgtkglext1-dev
  
 
==Building==
 
==Building==
Line 89: Line 92:
 
./build/vegastrike --debug=3 # to generate detailled logs for bug reporting
 
./build/vegastrike --debug=3 # to generate detailled logs for bug reporting
 
./build/setup/vssetup # to edit game settings
 
./build/setup/vssetup # to edit game settings
./build/mesh_tool/mesh_tool # mesh converter, for modding
+
./build/objconv/mesh_tool # mesh converter, for modding
 
</pre>
 
</pre>
  
Line 147: Line 150:
 
'''Note:''' The configure script currently has a bug that can cause it to incorrectly report on the absence of GLUT. If you are sure you have installed glut-devel and are still seeing this error, check  near the end of config.log to see if another library (such as libxmu or libxi) is the true culprit. [http://forums.vega-strike.org/viewtopic.php?t=7562]
 
'''Note:''' The configure script currently has a bug that can cause it to incorrectly report on the absence of GLUT. If you are sure you have installed glut-devel and are still seeing this error, check  near the end of config.log to see if another library (such as libxmu or libxi) is the true culprit. [http://forums.vega-strike.org/viewtopic.php?t=7562]
  
 +
=== Using Python 3 ===
 +
Install as above <code>libpython3.4 libpython3-all-dev libpython3.4-dbg</code> (not quite necessary, but if you're compiling a development version...)
 +
Then configure VS to use it. Simply typing a different version (e.g. "3.4") in cmake/ccmake is '''not''' enough - it may not even find the right files. Replace "2.7" to "3.4" in specific paths '''PYTHON_'''* paths. But that's not all - '''Boost_PYTHON_LIBRARY_'''* paths point at something like "/usr/lib/x86_64-linux-gnu/libboost_python.so", which is likely to be symlink to a ''Python 2'' library. In this case you'll get lots of errors like
 +
<pre>CMakeFiles/vegaserver.dir/src/cmd/script/director_server.cpp.o:director_server.cpp:(.text+0x139): more undefined references to `boost::python::detail::init_module(PyModuleDef&, void (*)())' follow
 +
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_Size'
 +
</pre> So check what this path really does:
 +
<pre>
 +
$ls -l /usr/lib/x86_64-linux-gnu/libboost_python*
 +
lrwxrwxrwx ... /usr/lib/x86_64-linux-gnu/libboost_python.so -> libboost_python-py27.so
 +
</pre> Now, back in Cmake replace it with whatever link on the list is appropriate for your version ("/usr/lib/x86_64-linux-gnu/libboost_python-py34.so" in our case).
  
 
====Make====
 
====Make====

Latest revision as of 18:09, 22 April 2015

arrow_left.png Compiling with Cygwin arrow_up.png HowTos Compiling from SVN on Mac OSX arrow_right.png

How to compile from SVN under Linux.

For specific instructions for Ubuntu see: HowTo:Checkout SVN (Ubuntu Linux)

For windows compiling see: HowTo:Cygwin Compiling, HowTo:VCPP Compiling

Getting the SVN-files

Requirements

In order to compile Vegastrike there are a few things to check:

  • Make sure you have these packages installed ...
    • make
    • gcc
    • automake at least version 1.6
    • autoconf at least version 2.53
    • X11...
    • libpng + libpng-devel <-- libpng 3 is recommended.
    • python and python-dev <-- 2.2.1 or above
    • expat + expat-devel
    • (lib)jpeg + libjpeg-devel
    • opengl (see below) (you probably already have it)
    • glut + glut-devel
    • openal + openal-devel
    • libgtk2.0 + libgtk2.0-devel
    • libfreeimage3 (vegastrike itself can compile without it, but mesher can't)
    • cmake (and cmake-curses-gui if you want to use more convenient ccmake)

On Debian, this probably should do the trick in (copy and paste the into terminal):

sudo apt-get install libpng12-0 libpng12-dev python-dev libexpat1-dev     \
        libjpeg62-dev freeglut3-dev libopenal-dev libgtk2.0-dev libogg-dev libvorbis-dev \
        build-essential libgl1-mesa-dev automake autoconf libsdl1.2-dev

On XUbuntu 12.10+, this should do the trick (copy and paste into terminal):

sudo apt-get install \
     build-essential cmake-curses-gui freeglut3-dev python-dev \
     lib{expat1,gl1-mesa,gtk2.0,jpeg-turbo8,ogg,openal,png12,sdl1.2,vorbis,xmu,xv}-dev


On fedora 17/18/19, this should do the trick (copy and paste into terminal):

sudo yum install \
     automake cmake gcc gcc-c++ glibc-devel kernel-devel make \
     {python,expat,freealut,freeglut,gtk2,libjpeg-turbo,libpng,libvorbis,openal-soft,SDL}-devel \
     lib{X11,Xdmcp,xkbfile,Xmu,Xpm,Xres,XScrnSaver,Xtst,Xv,Xxf86misc}-devel

Not strictly necessary, but to get as many used libraries as you can: x11proto-resource-dev libxkbfile-dev libxpm-dev libxres-dev libxv-dev libgtkglext1-dev

Building

The building and compiling process can be accomplished with two systems as of now. There's the classic autotools, and the newer (recommended) cmake. If you have cmake installed, you should try it.

With CMake (recommended)

Building with CMake is just building with Make, only the configure part can be done interactively, and all intermediate files are tidily put in their own folders:

cd ./vegastrike
mkdir build
cd build
ccmake ..  # this will pop up an interactive configuration screen, press "c" to autoconfigure, 
           # and once it's done "g" to generate everything and exit.
           # Or edit stuff and follow on-screen instructions if you know what you're doing.
make

If for some reason you want to see the compiler commands, you can press t while in ccmake and toggle the CMAKE_VERBOSE_MAKEFILE option from OFF to ON and press c to reconfigure and g to regenerate the Makefile.

Now you can run from the build folder:

cd ./vegastrike
./build/vegastrike # to play the game
./build/vegastrike --debug=3 # to generate detailled logs for bug reporting
./build/setup/vssetup # to edit game settings
./build/objconv/mesh_tool # mesh converter, for modding

With Autotools (deprecated)

The build procedure should look like the following listing. Remember the configure part depends on above requirements. Though autoconf may not work, if so just skip it.

cd ./vegastrike
./bootstrap-sh
./configure --enable-flags='-O3 -g'  # or --enable-debug to disable optimization.  -ffast-math will cause problems in code that checks for infinities. Note that in the first flag there's a capital 'o', not a zero.
make

Now you can run from the build folder:

cd ./vegastrike
./vegastrike # to play the game
./vegastrike --debug=3 # to generate detailled logs for bug reporting
./vssetup # to edit game settings
./mesher # mesh converter, for modding

Custom Makefile creation and usage

Configure

If you plan to install, when you're configuring:

  • To be sure set the data dir to your vs-data dir:
./configure --with-data-dir=<DIR> ........
  • When using libpng 1.2,
--with-png-inc=<DIR>

is needed. An example is

--with-png-inc=/usr/include/libpng12/
  • If you don't want to compile with GTK just turn it off, however you will not get a setup program if you do this:
./configure --disable-gtk ...........
  • If you only want the server, and want to disable all GUI components--This removes the dependency on X11, OpenGL, SDL, GLUT, OpenAL.
./configure --disable-client ...........
  • See this thread about boost versions. Set this option to 1.28, 1.29, 1.33, or "system" if the default does not compile.
./configure --with-boost=<VER> ...........

You will likely receive some error messages during any of these stages, especially during the configure part. If they tell you that your system is missing some development libraries, install them. How this is done depends on your Linux distribution, but we will assist you in the Compiling Problems forums. You will be left with a file called "config.log" please attach that instead of copy-and-pasting thousands of lines of error messages. It's all in this file.

After you installed the missing libraries repeat the last (failed) step and continue.


Note: The configure script currently has a bug that can cause it to incorrectly report on the absence of GLUT. If you are sure you have installed glut-devel and are still seeing this error, check near the end of config.log to see if another library (such as libxmu or libxi) is the true culprit. [1]

Using Python 3

Install as above libpython3.4 libpython3-all-dev libpython3.4-dbg (not quite necessary, but if you're compiling a development version...) Then configure VS to use it. Simply typing a different version (e.g. "3.4") in cmake/ccmake is not enough - it may not even find the right files. Replace "2.7" to "3.4" in specific paths PYTHON_* paths. But that's not all - Boost_PYTHON_LIBRARY_* paths point at something like "/usr/lib/x86_64-linux-gnu/libboost_python.so", which is likely to be symlink to a Python 2 library. In this case you'll get lots of errors like

CMakeFiles/vegaserver.dir/src/cmd/script/director_server.cpp.o:director_server.cpp:(.text+0x139): more undefined references to `boost::python::detail::init_module(PyModuleDef&, void (*)())' follow
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_Size'
So check what this path really does:
$ls -l /usr/lib/x86_64-linux-gnu/libboost_python*
lrwxrwxrwx ... /usr/lib/x86_64-linux-gnu/libboost_python.so -> libboost_python-py27.so
Now, back in Cmake replace it with whatever link on the list is appropriate for your version ("/usr/lib/x86_64-linux-gnu/libboost_python-py34.so" in our case).

Make

The final step for compiling is the make command. The Makefile should be able to compile most of the included utilities.

To compile mesher, for example, type:

make mesher
  • Running
make all-am

reduces memory usage while compiling because there's only one instance of make instead of two. From this forum thread.

  • The step
make install

is optional as the program is quite happy running in userland.

Note: You should not need to type "make clean", however if you experience errors like "unresolved external symbol" it may remedy that error.

Note: If you receive error without any mention of missing library (or something like) after very long line about running g++, try to set proper permissions or simply force your way through it and see whether it's your problem (if you're superuser). It looks like that:

collect2: ld returned 1 exit status
make[1]: *** [vegastrike] Error 1
make[1]: Leaving directory `/home/username/Games/VegaStrike/vegastrike'
make: *** [all] Error 2
~/Games/VegaStrike/vegastrike$ sudo make

Install

Installing is not really necessary to play, but you can do it if you wish to have the game accessible to all users. Otherwise, you can play by executing binary after it's built by the compiler.

If you do want to install, you'll need root access:

sudo make install

Setup and run the development version

Setup

This step is not necessary — the binaries should normally figure out where they are with respect to the data directory, but if the version you are using can't do this then you may need to follow these instructions.

To run Vega Strike, the built executables need all the configuration and data files to be in the right place relative to them. Currently, the executables (vegastrike and vssetup) reside in the source code directory. But they can be run out of the data directory. Therefore, we can create a link.

  • Change in to the data directory. (We are still in the source code directory vegastrike.)
~/VegaStrike/vegastrike> cd ../data
  • Create symbolic links to the executables in the source code directory.
~/VegaStrike/data> ln -s ../vegastrike/vegastrike
~/VegaStrike/data> ln -s ../vegastrike/vssetup
  • After that, you must run "./vssetup" inside the data folder, or any folder which has the correct setup.config and vegastrike.config.

If we had made copies or moved the files instead of symbolic linking, we would have to do the procedure of copying or moving every time we build the executables from source.

Running and configuring

  • To run Vega Strike you can normally start vegastrike from the vegastrike module you downloaded and built it in.
~/VegaStrike/vegastrike> ./vegastrike

Otherwise on other older versions you may have to start it from the data directory after copying or symbolic linking it as per the earlier instructions.

~/VegaStrike/data> ./vegastrike
  • Optionally you can create a short cut to this application onto your desktop or desktop menus. Simply find your menu editor and point it to the vegastrike executable.
  • If you need to adjust screen resolutions, input devices and key-mappings, do so by editing the configuration file vegastrike.config. The default configuration file resides in the data directory. You can change that or you can make your own user specific version by first copying it into your .vegastrike (hidden directory) directory in your user's home directory.

See also

FIXME These links are broken and they are very old from 2003 and most likely becoming irrelevant if someone knows for sure please update the links and put them in the right location, or delete FIXME


arrow_left.png Compiling with Cygwin arrow_up.png HowTos Compiling from SVN on Mac OSX arrow_right.png