The International Simutrans Forum

Development => Technical Documentation => Topic started by: An_dz on February 14, 2017, 03:04:14 AM

Title: How to compile Simutrans/makeobj on Windows with Mingw-w64 (old)
Post by: An_dz 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.
make                      (the guy that reads instructions to compile)
autoconf                  (for automatic configuration)
mingw-w64-i686-gcc        (the actual compiler)
mingw-w64-i686-SDL        (only if you want an SDL1 build)
mingw-w64-i686-SDL_mixer  (only if you want sound on an SDL1 build)
mingw-w64-i686-SDL2       (only if you want an SDL2 build)
mingw-w64-i686-SDL2_mixer (only if you want sound on an SDL2 build)
mingw-w64-i686-freetype   (for scaleable font support)
#do not use, broken for now: mingw-w64-i686-miniupnpc  (for easy server option)
mingw-w64-i686-zstd       (if you want zstd compression support) 
mingw-w64-i686-libpng     (for makeobj)
mingw-w64-i686-pkg-config (for makeobj)


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

Warning: pacman keeps a cache of the installed packages and never deletes them. To manually delete this cache run pacman -Scc from time to time and accept all questions.

EDIT: adding libzstd to package list
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: HyperSim 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.


===> 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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: Ters 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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: JHSDF 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)


===> 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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: HyperSim on August 15, 2017, 09:03:24 AM
QuoteWhich 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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: Ters 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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: JHSDF on August 15, 2017, 12:37:59 PM
this is r8264 too. make ang gcc version are here.

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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: Ters 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?
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: JHSDF on August 15, 2017, 02:46:48 PM
This is the contents set up by hand.


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?
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: Ters 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.
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: HyperSim 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!! :)
Title: Re: How to compile Simutrans/makeobj with Mingw-w64
Post by: JHSDF 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!
Title: Re: How to compile Simutrans/makeobj on Windows with Mingw-w64
Post by: An_dz 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.
Title: Re: How to compile Simutrans/makeobj on Windows with Mingw-w64
Post by: An_dz 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.
Title: Re: How to compile Simutrans/makeobj on Windows with Mingw-w64
Post by: prissi on December 03, 2019, 12:13:18 PM
Update: With the mingw libminiupnp you can only link dynamically. Static linking requires to build the lib yourself. They solved that issue once, but it reappeared.