Lade...
 

Beiträge zu en_Cross-Compiling_Simutrans (gegenwärtige Version)

Prozess



Optionen




Version
Version Datum Nutzer
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Roboron3042
Seite anzeigen

Statistiken

Autor Wörter Leerraum Zeichen Druckbare Zeichen
Benutzt Gelöscht Benutzt Gelöscht Benutzt Gelöscht Benutzt Gelöscht
Roboron3042 1031 (100.0%) 0 (0.0%) 677 (100.0%) 0 (0.0%) 13036 (100.0%) 0 (0.0%) 9581 (100.0%) 0 (0.0%)
Gesamt 1031 (100.0%) 0 (100.0%) 677 (100.0%) 0 (100.0%) 13036 (100.0%) 0 (100.0%) 9581 (100.0%) 0 (100 %)

Seitenänderungen

Inhaltsverzeichnis

  • <a href='#Setting_up_the_enviroment' class='link'>Setting up the enviroment</a>
    • <a href='#Installing_mingw64_from_your_distribution' class='link'>Installing mingw64 from your distribution</a>
      • <a href='#Installing_mingw64_on_Fedora' class='link'>Installing mingw64 on Fedora</a>
      • <a href='#Installing_mingw64_on_Arch_Linux' class='link'>Installing mingw64 on Arch Linux</a>
    • <a href='#Installing_mingw64_from_MXE' class='link'>Installing mingw64 from MXE</a>
  • <a href='#Cross-Compilitaion' class='link'>Cross-Compilitaion</a>
    • <a href='#Compiling_miniupnpc' class='link'>Compiling miniupnpc</a>
    • <a href='#Compiling_Simutrans' class='link'>Compiling Simutrans</a>
    • <a href='#Known_Issues' class='link'>Known Issues</a>

After successfully compiling Simutrans, you may be tempted to set up a Cross-Compilation Enviroment to build Simutrans for Windows from your Linux machine. Cross-compilation of Simutrans is indeed posible and made nightly on build servers, like the
<a class="wiki external" target="_blank" title="External link" href="http://bridgewater-brunel.me.uk/" rel="external nofollow">bridgewater-brunel</a> server that builds Simutrans-Extended. Depending on your system, setting up the enviroment is different, but in the end, all of then will be using mingw64, a cross-compilation platform, so steps for cross-compiling are the same after the set up.

Setting up the&nbsp;enviroment<a href="#Setting_up_the_enviroment" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>

For installing mingw64 on a GNU/Linux machine, you generally have two options: install from your distribution repositories or install the MXE enviroment. The first option can be more difficult depending on your distribution, but will integrate better. The second option works in any distribution and it is always easy to setup, but linking dynamically will generate an enormous executable (30MB vs the usual 10MB executable), because MXE is set up in such away that all libraries are either dinamically linked or statically linked.

Installing mingw64 from your&nbsp;distribution<a href="#Installing_mingw64_from_your_distribution" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>


Installing mingw64 on&nbsp;Fedora<a href="#Installing_mingw64_on_Fedora" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>

Copy to clipboard
sudo dnf -y upgrade &amp;&amp; sudo dnf -y install mingw32-nsis mingw64-pkg-config mingw64-gcc mingw64-gcc-c++ mingw64-SDL2-static mingw64-zlib-static mingw64-bzip2-static mingw64-libpng-static mingw64-winpthreads-static mingw64-freetype-static


Installing mingw64 on Arch&nbsp;Linux<a href="#Installing_mingw64_on_Arch_Linux" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>


On official repositories you only have the basic toolchain.
Copy to clipboard
sudo pacman -S mingw64


For dependencies, you can install them from the AUR (they are all there) which means that they will be compiled before. If you prefer to get the binaries instead, you can add the
<a class="wiki external" target="_blank" title="External link" href="https://martchus.no-ip.biz/repo/arch/ownstuff/" rel="external nofollow"> ownstuff repository</a> to your /etc/pacman.conf
Copy to clipboard
yay -S mingw-w64-bzip2 mingw-w64-freetype2 mingw-w64-libpng mingw-w64-miniupnpc mingw-w64-pkg-config mingw-w64-sdl2 mingw-w64-zlib mingw-w64-zstd


Installing mingw64 from&nbsp;MXE<a href="#Installing_mingw64_from_MXE" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>

First get the project from GitHub.
Copy to clipboard


cd into the directory and build the dependencies, setting MXE_TARGETS to "x86_64-w64-mingw32.static" or "x86_64-w64-mingw32.dynamic" depending on your needs.
Copy to clipboard
make MXE_TARGETS='x86_64-w64-mingw32.static' bzip2 cc freetype libpng sdl2 zlib zstd

This will build all necessary dependencies. If you don't want to compile them (it will take a while), you can also download binaries from
<a target="_blank" class="wiki external" href="https://pkg.mxe.cc/">https://pkg.mxe.cc/<span class="icon icon-link-external external_link" ><img src="img/icons/external_link.gif" alt="link-external"></span></a>

Now you can optionally move the enviroment to a system directory
Copy to clipboard
sudo mv mxe /opt/mxe


Cross-Compilitaion<a href="#Cross-Compilitaion" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>


Compiling miniupnpc<a href="#Compiling_miniupnpc" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>

You may have noticed that we have not compiled miniupnpc previously. This is due to miniupnpc currently shipping a broken lib, soy you have to build it yourself in your brand new enviroment. You can use the following shell script for that, which will install miniupnpc to your enviroment. You have to change accordingly the first three variables, everything else don't need any modifications.
Copy to clipboard
# Change to yours. For example, for MXE static would be x86_64-w64-mingw32.static CROSS=x86_64-w64-mingw32
  1. Default if installed via distribution. Change to yours.
MINGW_PATH=/usr/$CROSS
  1. Default if installed via distribution. Change to yours. For example, for MXE static would be &quot;/path/to/mxe/usr/x86_64-w64-mingw32.static/usr/bin:$PATH&quot;
PATH=/usr/$CROSS/bin:$PATH rm -rf master.zip wget https://github.com/miniupnp/miniupnp/archive/master.ziplink-external unzip -o master.zip cd miniupnp-master/miniupnpc cat Makefile.mingw | sed 's|\twingenminiupnpcstrings.exe |'&quot;$(printf '\t')&quot;'./wingenminiupnpcstrings.exe |' &gt;Makefile.mingw2 make -f Makefile.mingw DLLWRAP=$CROSS-dllwrap CC=$CROSS-gcc AR=$CROSS-ar cp libminiupnpc.a $MINGW_PATH/lib cp *.h $MINGW_PATH/lib mkdir $MINGW_PATH/include/miniupnpc cp *.h $MINGW_PATH/include/miniupnpc cd ../.. rm -rf master.zip rm -rf miniupnp-master


Compiling Simutrans<a href="#Compiling_Simutrans" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>

First. add the mingw64 bin path to your path, if not already added:
Copy to clipboard
PATH=/path/to/mingw64/bin:$PATH


For compiling the game, we can set up the config.default file the same way we do for mingw on Windows, but will have to add some lines to config.default:
Copy to clipboard
CC=$(CROSS)gcc CXX=$(CROSS)g++ LD=$(CROSS)ld WINDRES=$(CROSS)windres PKG_CONFIG=$(CROSS)pkg-config FREETYPE_CONFIG=$(CROSS)pkg-config freetype2 SDL2_CONFIG=$(CROSS)pkg-config sdl2


Those lines will make sure that we use the tools (gcc, g++, etc) from the cross-compiler enviroment, instead of the system tools. Now, we can finally type (adjusting CROSS value to your enviroment):
Copy to clipboard
make CROSS=x86_64-w64-mingw32-


And Simutrans will compile a windows executable!

Known Issues<a href="#Known_Issues" class="heading-link"><span class="icon icon-link link" ><img src="img/icons/link.png" alt="link"></span></a>

If in the linking phase you get some errors regarding freetype or other libraries with undefined references to functions like "__chk_fail", you may need to add the following to your config.default:
Copy to clipboard
LDFLAGS += -fstack-protector


This is known to happen on Arch Linux, provided you installed dependencies from the AUR (10-2020).

Online Benutzer

17 Benutzer (alle) online

Neueste Forenbeiträge