The International Simutrans Forum

 

Author Topic: How to compile Simutrans/makeobj on Windows with Mingw-w64  (Read 10205 times)

0 Members and 1 Guest are viewing this topic.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
How to compile Simutrans/makeobj on Windows with Mingw-w64
« on: February 14, 2017, 03:04:14 AM »
Well, I think it's worth showing a little tutorial here to show how simple you can compile Simutrans for Windows with Mingw + MSYS2.
  • Install MSYS2, both versions compile for x86 & x64 so install the version according to your version of Windows, if you have a x64 Windows download and install the x64 version.
  • At the end of the installation keep the checkbox to run MSYS
  • In the window that opens run pacman -Syu
  • A message might show telling to close MSYS. Do so and accept the message telling to terminate any running program.
  • Open MSYS2 MSYS from Start menu
  • Run again pacman -Syu until no updates are found
  • Install the following packages with pacman -S PackageName, where PackageName is:
Code: [Select]
make
mingw-w64-i686-gcc
mingw-w64-i686-SDL (Only if you want an SDL build OR for sound on SDL2)
mingw-w64-i686-SDL2 (Only if you want an SDL2 build)
mingw-w64-i686-freetype (for scaleable font support)
mingw-w64-i686-miniupnpc (for easy server option)
mingw-w64-i686-libpng (for makeobj)
mingw-w64-i686-pkg-config (for makeobj)
  • Now that your are setup, you can close this window
  • And now for the configuration there are two options:
    • Automatic configuration (The easiest)
      • Open MSYS2 MinGW 32-Bit from Start menu
      • In this window navigate to the root simutrans directory with cd simutrans_path and then type ./configure
      • This should create a config.default suited for your system. If this fails, you can use the manual method.
    • Manual method
      • Open the root simutrans directory and make a copy of the file config.template and rename it config.default
      • Open config.default with a text editor and un-comment the lines that you need
        • BACKEND is pretty obvious, the only one that is not is that posix is for compiling without graphics (server)
        • COLOUR_DEPTH is if you want with graphics (16) or without (0 / server)
        • OSTYPE must be mingw for obvious reasons
        • Un-comment PNG_CONFIG if you will compile makeobj
        • Un-comment SDL_CONFIG or SDL2_CONFIG according to the SDL version you'll use
        • The others are documented in the file
  • Now that you have a config.default file you can compile Simutrans
  • Open MSYS2 MinGW 32-Bit from Start menu, if not open already
  • In this window navigate to the root simutrans directory with cd simutrans_path and run make
  • Congratulations, you now have an executable in your build directory

Whenever you feel you want to update the packages run MSYS2 MSYS and call pacman -Syu

edited by prissi on 18-May-2018
« Last Edit: May 22, 2018, 08:28:03 PM by An_dz »

Offline HyperSim

  • *
  • Posts: 104
  • Languages: EN, JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #1 on: August 14, 2017, 12:33:07 PM »
I followed this instruction and the topic below.
http://forum.simutrans.com/index.php?topic=6556.0
However I could not compile the program but minGW gave me a lot of error message like this.

Code: [Select]
===> LD  /c/users/master/documents/github/simutrans/sim
build/default/descriptor/sound_desc.o: In function `ZN12sound_desc_t12get_sound_idEPKc':
(dir)/descriptor/sound_desc.cc:105: undefined reference to `dr_load_sample(char const*)'
...
(many error message saying 'undefined reference to XXX')
...
collect2.exe: error: ld returned 1 exit status
make: *** [common.mk:22: (dir)/simutrans/sim] error

Tell me what to do to solve this problem.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5340
  • Languages: EN, NO
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #2 on: August 14, 2017, 02:18:26 PM »
Which revision are you trying to compile? The Makefile appears to have been broken for a few days recently, but it should have been fixed by now.

Offline JHSDF

  • *
  • Posts: 19
  • player of pak128.japan
    • SimuEXPO
  • Languages: JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #3 on: August 15, 2017, 05:21:37 AM »
I saw the same message in msys2 minGW 32bit.

Last messages of msys2 is (maybe HyperSim also saw these message during abridgement of code)

Code: [Select]
===> LD  /c/users/JHSDF/documents/github/simutrans/sim
build/default/descriptor/sound_desc.o: In function `ZN12sound_desc_t12get_sound_idEPKc':
C:\users\JHSDF\documents\github\simutrans/descriptor/sound_desc.cc:105: undefined reference to `dr_load_sample(char const*)'
....

(similar messages like
undefined reference to `get_system_color(unsigned int, unsigned int, unsigned int)'
undefined reference to `dr_time()'
undefined reference to `move_pointer(int, int)'
undefined reference to `_imp__getaddrinfo@16'
undefined reference to `_imp__WSAGetLastError@0'
undefined reference to `_imp__getaddrinfo@16'
undefined reference to `gai_strerrorA'
undefined reference to `_imp__getnameinfo@28'
undefined reference to `gai_strerrorA'
undefined reference to `_imp__socket@12'
undefined reference to `_imp__WSAGetLastError@0'
undefined reference to `_imp__bind@12'
undefined reference to `_imp__WSAGetLastError@0'
undefined reference to `_imp__getnameinfo@28'
undefined reference to `gai_strerrorA'
undefined reference to `_imp__connect@12'
undefined reference to `_imp__WSAGetLastError@0'
undefined reference to `_imp__freeaddrinfo@4'
undefined reference to `_imp__freeaddrinfo@4'
undefined reference to `_imp__WSAGetLastError@0'
undefined reference to `dr_sleep(unsigned int)'
undefined reference to `dr_time()'
undefined reference to `show_pointer(int)'
undefined reference to `set_pointer(int)'
undefined reference to `dr_sleep(unsigned int)'
undefined reference to `dr_prepare_flush()'
undefined reference to `dr_flush()'
undefined reference to `dr_prepare_flush()'
undefined reference to `dr_flush()'
undefined reference to `set_pointer(int)'
undefined reference to `dr_prepare_flush()'
undefined reference to `dr_flush()'

and more)


C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.1.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o): In function `main':
C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make: *** [common.mk:22: /c/users/JHSDF/documents/github/simutrans/sim] error 1

I have no idea to avoid this error and where code, library or makefile is wrong.
I tried using makefile fixed 5days ago, but compiling is still failed.

I want a hint to do.

Offline HyperSim

  • *
  • Posts: 104
  • Languages: EN, JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #4 on: August 15, 2017, 09:03:24 AM »
Quote
Which revision are you trying to compile?
I use the revesion r8264.  I got the source about a month ago, so I don't think this error is caused by the Makefile.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5340
  • Languages: EN, NO
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #5 on: August 15, 2017, 11:50:35 AM »
I have compiled both r8269 and r8279 successfully with Mingw-w64 from MSYS2. What does make --version and gcc --version say? And are you building the GDI, SDL or SDL2 version? I have only tested the GDI version.

Offline JHSDF

  • *
  • Posts: 19
  • player of pak128.japan
    • SimuEXPO
  • Languages: JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #6 on: August 15, 2017, 12:37:59 PM »
this is r8264 too. make ang gcc version are here.

Code: [Select]
GNU Make 4.2.1

Using built-in specs.
COLLECT_GCC=C:\msys64\mingw32\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.1.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../gcc-7.1.0/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2
Thread model: posix
gcc version 7.1.0 (Rev2, Built by MSYS2 project)

I tried GDI version.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5340
  • Languages: EN, NO
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #7 on: August 15, 2017, 01:15:49 PM »
That's the same I've got. What is the contents of config.default? Was it set up by hand or using the configure script?

Offline JHSDF

  • *
  • Posts: 19
  • player of pak128.japan
    • SimuEXPO
  • Languages: JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #8 on: August 15, 2017, 02:46:48 PM »
This is the contents set up by hand.

Code: [Select]
BACKEND = gdi
COLOUR_DEPTH =16
OSTYPE = mingw
DEBUG = 3
WITH_REVISION = 8264
WIN32_CONSOLE = 1

MULTI_THREAD = 1
STATIC = 1

MAKEOBJ_PROGDIR = $(shell pwd)
NETTOOL_PROGDIR = $(shell pwd)
PROGDIR = $(shell pwd)

Is there anything wrong or shortage?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5340
  • Languages: EN, NO
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #9 on: August 15, 2017, 03:28:38 PM »
Some of your defines have a space or something at the end. Maybe that is enough to make it fail. The errors are consistent with BACKEND not being set correctly, and that one has a space at the end. That OSTYPE also has a space will probably not be obvious until later on, if at all, since some of the checks for OSTYPE mingw before the recent changes probably ignore the space by accident.

Offline HyperSim

  • *
  • Posts: 104
  • Languages: EN, JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #10 on: August 16, 2017, 12:56:05 AM »
I checked my config.default and remove space, and now I succeed in compiling simutrans!  Thank you very much!! :)

Offline JHSDF

  • *
  • Posts: 19
  • player of pak128.japan
    • SimuEXPO
  • Languages: JP
Re: How to compile Simutrans/makeobj with Mingw-w64
« Reply #11 on: August 16, 2017, 01:36:18 AM »
I also removed space from config.default and replace. Compiliation was successful! Thank you very much Ters!

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: How to compile Simutrans/makeobj on Windows with Mingw-w64
« Reply #12 on: April 20, 2018, 05:27:44 PM »
I added some basic steps for creating a config.default file now so it's even easier.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: How to compile Simutrans/makeobj on Windows with Mingw-w64
« Reply #13 on: May 22, 2018, 08:30:19 PM »
I've fixed and updated the miniupnpc package and the MinGW team has now put it upstream, if you had downloaded the attached zip you can now use the version that comes with MinGW.