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

0 Members and 1 Guest are viewing this topic.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2593
  • Total likes: 289
  • Helpful: 89
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
How to compile Simutrans/makeobj 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 -Syuu
  • 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 -Syuu 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-libpng (for makeobj)
mingw-w64-i686-pkg-config (for makeobj)
  • It's done, you can now close this window and open MSYS2 MinGW 32-Bit from Start menu
  • In the window that opens navigate to the folder where Simutrans is with cd path_to_simutrans and run make
  • Whenever you feel you want to update the packages run MSYS2 MSYS and call pacman -Syuu
« Last Edit: April 04, 2017, 07:22:21 PM by An_dz »

Offline HyperSim

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: 4674
  • Total likes: 170
  • Helpful: 108
  • 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

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

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: 4674
  • Total likes: 170
  • Helpful: 108
  • 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

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: 4674
  • Total likes: 170
  • Helpful: 108
  • 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

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: 4674
  • Total likes: 170
  • Helpful: 108
  • 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

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

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!