Difference between revisions of "MG/Linux Compiling"

From MegaGlest
Jump to navigation Jump to search
(just a little clean up to bring step 5 down to a new line)
 
 
(50 intermediate revisions by 9 users not shown)
Line 1: Line 1:
'''Linux Compiling:'''
+
This page explains how to compile [[MegaGlest]] on Linux platforms.
  
1. [[MG/Getting The Code|Get the project ]] from [[MG/SVN Structure|SVN]] using the commandline or your favorite SVN tool ([http://www.rabbitvcs.org/ rabbitvcs] or [http://tortoisesvn.tigris.org/ tortoise])<br />
+
===Linux quick setup===
2. Download package dependencies for your Linux distribution (see '''mk/linux/setupBuildDeps.sh''' which can do that for Debian,
+
[[MG/Getting The Code#Linux quick setup|''See here'']]
Ubuntu, Fedora and Open SuSE based distro's). The following is the current dependency list:
 
  
'''jpeg, lua5.1, png, SDL, openal, curl, xerces-c, ogg, vorbis, vorbisfile, vorbisenc, z, GL, GLU, SDLmain, ''''''ircclient'''''' (and the tools require wx)'''
+
==Requirements==
 +
*[[MG/Getting The Code|''Download the project'']] from the GIT repository using the command line (recommended) or your favorite GIT tool (such as [http://www.rabbitvcs.org/ RabbitVCS] or [https://code.google.com/p/tortoisegit/ TortoiseGIT]).
 +
*Install build dependencies. These are usally packaged by Linux distributions. On '''Debian, Ubuntu, Fedora, Opensuse and even more Linux distributions''' you may use
 +
cd mk/linux
 +
sudo ./setupBuildDeps.sh
 +
to install them. If your distribution is not supported or you prefer to install yourself: This is the current dependency list - where packages are available, the package names may start with ''lib'' and usually have ''-dev(el)'' towards the end:
  
<u>'''3.1 Build using CMake by Script'''</u>
+
<tt>gcc gcc-c++ cmake sdl2 alut GL GLU vorbis x11 lua jpeg png curl ircclient glew ftgl fribidi cppunit vlc miniupnpc</tt>
  
Go to the directory ''megaglest''.
+
Additionally for map editor and model viewer:
  
*On linux run ''build-mg.sh''
+
<tt>wxgtk xml2</tt>
  
*On windows run ''build-mg.bat''
+
==Compilation==
 +
*Update the branch you are working in with the [https://docs.megaglest.org/MG/Getting_The_Code#Update_the_source_code latest GIT code]
 +
===Scripted build ===
 +
(''Recommended way'')
 +
*Start the build:
 +
cd mk/linux
 +
./build-mg.sh
 +
*To start MegaGlest:
 +
./megaglest
  
*To compile for windows under linux run ''build-mg-win32.sh''
+
===Building using CMake by Hand===
 
+
*Open a terminal window and navigate to '''the specified branch''' and type the following:
<u>'''3.2 Build using CMake by Hand'''</u>
+
cd mk/linux
 
+
mkdir build
a. Open a terminal window and navigate to '''trunk (or the specified branch)''' and type the following:
+
cd build
 +
cmake ../../..
 +
make
 +
*In the line <tt>cmake ../../..</tt> you can put additional parameters <tt>cmake <parameters> ../../..</tt> where every parameter should be preceded by <tt>-D</tt>.
 +
*NOTE: most developer that are not planning to run megaglest from the standard linux LHS paths (like usr/local/bin) should run cmake with the following syntax so that the resulting binaries look in the local compiled folders for data files:
 +
cd mk/linux
 
  mkdir build
 
  mkdir build
 
  cd build
 
  cd build
  cmake ..
+
  cmake -DCMAKE_INSTALL_PREFIX='' -DWANT_DEV_OUTPATH=ON ../../..
 
  make
 
  make
b. If nothing goes wrong you will see '''glest.bin''' (and other binaries) in the same folder ('''mk/linux''').
 
'''Notes:'''
 
  
The follow are build types supported using cmake:
+
As example other special CMake options for customized builds:
  Release, Debug, RelWithDebInfo and MinSizeRel
+
  -DBUILD_MEGAGLEST=On
To change the build type execute cmake as follows (default is Release):
+
-DBUILD_MEGAGLEST_MAP_EDITOR=On
  cmake -D CMAKE_BUILD_TYPE=Debug ..
+
-DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=On
<u>'''4. (Optional) Cross Compiling Windows binaries on Linux using MingW:'''</u>
+
-DBUILD_MEGAGLEST_MODEL_VIEWER=On
 +
-DWANT_STATIC_LIBS=On
 +
  -DMINIUPNPC_VERSION_PRE1_6=Off
 +
...
 +
but if you want to see this list ^ up to date (and with useful description) then use <tt>cmake -LH ../../..</tt> on the beginning.
  
a) Download and extract the MingW win32 dependency archive from [https://sourceforge.net/projects/megaglest/files/win32_deps_mingw.7z/download here] and extract under the '''source''' folder.
+
==Cross Compiling Windows binaries on Linux==
 +
*This process is still experimental and is not fully supported at the moment but rather for educational purposes.
 +
*Download and extract the MingW win32 dependency archive from [https://sourceforge.net/projects/megaglest/files/win32_deps_mingw.7z/download Sourceforge] and extract into the <tt>source</tt> folder.
 +
*Install the MingW cross compiler for your distro. In Ubuntu run:
 +
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
 +
*Open a terminal and <tt>cd</tt> to the root folder of your Mega-Glest folder.
 +
*Modify the script. You also need to change <tt>windows_deps/curl-7.20.1</tt> to <tt>windows_deps/curl-7.21.3</tt>
 +
*Run the script:
 +
cd mk/linux
 +
./build-mg-win.sh
 +
*If all goes well you should see the Windows <tt>.exe</tt> binaries produced in the <tt>data/glest_game</tt> folder.
  
b) Install the MingW cross compiler for your distro. In Ubuntu run:
+
==Test binaries==
 +
To test running the game, run the binary '''in <tt>mk/linux</tt>''' like this:
 +
./megaglest
  
  '''sudo apt-get install mingw32 mingw32-binutils mingw32-runtime'''
+
These are some commandline options:
c) Open a terminal and cd to the root folder of your Mega-Glest folder (usually trunk)
+
  ./megaglest --help
 +
./megaglest --version
 +
./megaglest --opengl-info
  
d) Modify the script:
+
==Trouble shooting==
You also need to change ''win32_deps/curl-7.20.1'' to'' win32_deps/curl-7.21.3''
+
If your build fails, and you have not been building for a while, this is usually due to '''outdated build dependencies''' and in this case you should do:
e) Run the script:
+
cd mk/linux
 +
sudo ./setupBuildDeps.sh
 +
If MegaGlest crashes you should '''do a full rebuild'''. To trigger a full rebuild you should just remove the <tt>build</tt> directory before the build, e.g. by run:
 +
cd mk/linux && rm -r build && ./build-mg.sh
  
'''./build-mg-win.sh'''
+
==Reporting bugs==
f) If all goes well you should see the Windows *.exe binaries produced in the '''data/glest_game''' folder.
+
If you think you have run into a bug in MegaGlest, and neither reading the [http://readme.megaglest.org/ README] and [http://faq.megaglest.org/ FAQ] nor searching for it at http://bugs.megaglest.org helps, then please report a new bug at http://bugs.megaglest.org/ (one-time registration is necessary to post).
 
+
When filing a bug, please provide a log of the build process of a '''full rebuild'''.
<u>'''5. Test binaries'''</u>
 
 
 
1. To test running the game, run the binary in mk/linux like this:
 
./glest.bin
 
 
 
These are some commandline options:
 
./glest.bin --help
 
./glest.bin --version
 
./glest.bin --opengl-info
 
  
'''There are some more useful scripts here''': [[MG/Misc Scripts|Misc Scripts]]
+
==See Also==
 +
*[[MegaGlest]]
 +
*[[MG/Misc Scripts|Miscellaneous MegaGlest Scripts]]
 +
*[[MG/Mac Compiling|Mac Compiling]]
 +
*[[MG/Windows Compiling|Windows Compiling]]
 +
*[[MG/FreeBSD Compiling|FreeBSD Compiling]]
 
[[Category:MG]]
 
[[Category:MG]]
 +
[[Category:Compiling]]
 +
[[Category:Development]]

Latest revision as of 01:28, 13 December 2019

This page explains how to compile MegaGlest on Linux platforms.

Linux quick setup[edit]

See here

Requirements[edit]

  • Download the project from the GIT repository using the command line (recommended) or your favorite GIT tool (such as RabbitVCS or TortoiseGIT).
  • Install build dependencies. These are usally packaged by Linux distributions. On Debian, Ubuntu, Fedora, Opensuse and even more Linux distributions you may use
cd mk/linux
sudo ./setupBuildDeps.sh

to install them. If your distribution is not supported or you prefer to install yourself: This is the current dependency list - where packages are available, the package names may start with lib and usually have -dev(el) towards the end:

gcc gcc-c++ cmake sdl2 alut GL GLU vorbis x11 lua jpeg png curl ircclient glew ftgl fribidi cppunit vlc miniupnpc

Additionally for map editor and model viewer:

wxgtk xml2

Compilation[edit]

Scripted build[edit]

(Recommended way)

  • Start the build:
cd mk/linux
./build-mg.sh
  • To start MegaGlest:
./megaglest

Building using CMake by Hand[edit]

  • Open a terminal window and navigate to the specified branch and type the following:
cd mk/linux
mkdir build
cd build
cmake ../../..
make
  • In the line cmake ../../.. you can put additional parameters cmake <parameters> ../../.. where every parameter should be preceded by -D.
  • NOTE: most developer that are not planning to run megaglest from the standard linux LHS paths (like usr/local/bin) should run cmake with the following syntax so that the resulting binaries look in the local compiled folders for data files:
cd mk/linux
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX= -DWANT_DEV_OUTPATH=ON ../../..
make

As example other special CMake options for customized builds:

-DBUILD_MEGAGLEST=On
-DBUILD_MEGAGLEST_MAP_EDITOR=On
-DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=On
-DBUILD_MEGAGLEST_MODEL_VIEWER=On
-DWANT_STATIC_LIBS=On
-DMINIUPNPC_VERSION_PRE1_6=Off
...

but if you want to see this list ^ up to date (and with useful description) then use cmake -LH ../../.. on the beginning.

Cross Compiling Windows binaries on Linux[edit]

  • This process is still experimental and is not fully supported at the moment but rather for educational purposes.
  • Download and extract the MingW win32 dependency archive from Sourceforge and extract into the source folder.
  • Install the MingW cross compiler for your distro. In Ubuntu run:
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
  • Open a terminal and cd to the root folder of your Mega-Glest folder.
  • Modify the script. You also need to change windows_deps/curl-7.20.1 to windows_deps/curl-7.21.3
  • Run the script:
cd mk/linux
./build-mg-win.sh
  • If all goes well you should see the Windows .exe binaries produced in the data/glest_game folder.

Test binaries[edit]

To test running the game, run the binary in mk/linux like this:

./megaglest

These are some commandline options:

./megaglest --help
./megaglest --version
./megaglest --opengl-info

Trouble shooting[edit]

If your build fails, and you have not been building for a while, this is usually due to outdated build dependencies and in this case you should do:

cd mk/linux
sudo ./setupBuildDeps.sh

If MegaGlest crashes you should do a full rebuild. To trigger a full rebuild you should just remove the build directory before the build, e.g. by run:

cd mk/linux && rm -r build && ./build-mg.sh

Reporting bugs[edit]

If you think you have run into a bug in MegaGlest, and neither reading the README and FAQ nor searching for it at http://bugs.megaglest.org helps, then please report a new bug at http://bugs.megaglest.org/ (one-time registration is necessary to post). When filing a bug, please provide a log of the build process of a full rebuild.

See Also[edit]