News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

How to compile Simutrans/makeobj on Windows with Mingw-w64 (old)

Started by An_dz, February 14, 2017, 03:04:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

An_dz

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:
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)


  • Now that your are setup, you can close this window
  • And now for the configuration there are two options:

    • Automatic configuration (The easiest/You must have installed autoconf as specified above)

      • Open MSYS2 MinGW 32-Bit from Start menu
      • In this window navigate to the root simutrans directory with cd simutrans_path and then type autoconf && ./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

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

HyperSim

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.

Ters

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.

JHSDF

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.
My website has some addon for pak128.japan
http://kyuujitujieitai.wixsite.com/simuexpo

twitter https://twitter.com/kyuujitujieitai

HyperSim

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.

Ters

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.

JHSDF

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.
My website has some addon for pak128.japan
http://kyuujitujieitai.wixsite.com/simuexpo

twitter https://twitter.com/kyuujitujieitai

Ters

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?

JHSDF

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?
My website has some addon for pak128.japan
http://kyuujitujieitai.wixsite.com/simuexpo

twitter https://twitter.com/kyuujitujieitai

Ters

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.

HyperSim

I checked my config.default and remove space, and now I succeed in compiling simutrans!  Thank you very much!! :)

JHSDF

I also removed space from config.default and replace. Compiliation was successful! Thank you very much Ters!
My website has some addon for pak128.japan
http://kyuujitujieitai.wixsite.com/simuexpo

twitter https://twitter.com/kyuujitujieitai

An_dz

I added some basic steps for creating a config.default file now so it's even easier.

An_dz

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.

prissi

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.