News:

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

How to compile simutrans using MinGW

Started by prissi, January 02, 2011, 08:21:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prissi

Original found in the Experimetnal section by Turfit: But I copied to here too:



Follow http://wiki.openttd.org/Compiling_on_MinGW down through the Compiling libpng section - Simutrans doesn't need the rest of the libraires.
Deviations I made from the guide:
  1) Selected "Use current repository catalogues".
  2) Selected "MinGW Developer ToolKit" to install.
  3) Used not installed the SDL version from there
Don't know if this would make a difference...



bzip2 is needed for Simutrans: http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
No MinGW configuration so edit the makefile to change:

chmod a+x $(PREFIX)/bin/bzip2
chmod a+x $(PREFIX)/bin/bunzip2
chmod a+x $(PREFIX)/bin/bzcat
chmod a+x $(PREFIX)/bin/bzip2recover

to:

chmod a+x $(PREFIX)/bin/bzip2.exe
chmod a+x $(PREFIX)/bin/bunzip2.exe
chmod a+x $(PREFIX)/bin/bzcat.exe
chmod a+x $(PREFIX)/bin/bzip2recover.exe

or simply delete the lines... else the make will abort.

In MSYS run:

make install PREFIX=/mingw

to install.



For GDI - also require libunicows: http://prdownloads.sourceforge.net/libunicows/libunicows-1.1.1-mingw32.zip
Simply copy libunicows.a from the .zip into /mingw/lib



For SDL - also require SDL:
In MSYS:

wget http://www.libsdl.org/release/SDL-1.2.15.tar.gz
tar xvfz SDL-1.2.15.tar.gz
cd SDL-1.2.15
./configure ; make ; make install
cd ..


Will need the SDL.dll in your Simutrans directory to run. It's found in /usr/local/bin/SDL.dll in MSYS or \MinGW\msys\1.0\local\bin\SDL.dll in Windows.
or copy the precompiled/stripped .dll from inside http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz



You can add

  LDFLAGS ?= -static-libgcc -static-libstdc++

to the Simutrans Makefile MinGW section so I didn't need to hunt down even more dlls ...

If you get an error message about no CC found, add

CC = gcc

to config.default.



And, if you want to use the ./distribute.sh script you'll need a zip.exe: ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn.zip. I stuck it into /bin



And finally I get something that successfully compiles and runs both Simutrans-standard and -experimental in both GDI and SDL formats.

jamespetts

Thank you for this helpful guide. I am having some trouble, however, with installing bzip: I tried following the guidelines for zlip or libpng on the OpenTTD wiki, but they are not identical to each other, and neither worked for bzip.lib. As to the makefile amendments for bzlib - where should those additional lines go?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

TurfIt

makefile changes aren't new lines, either delete them or add the .exe extensions.


wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xvfz bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
{fix makefile as described above}
make install PREFIX=/mingw

doesn't work?



jamespetts

Ahh, that's very helpful - I had misunderstood Prissi's instructions and thought that it was Simutrans's not BZLib's makefile that needed to be edited. I have managed to make it compile now - thank you.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

Hmm - trying to compile under MinGW again to have a go with profiling, and for some reason having inexplicable trouble. When I run "make" (on the -devel branch), I get the following errors:


$ make
===> CXX clipboard_w32.cc
In file included from dataobj/../tpl/stringhashtable_tpl.h:8:0,
                 from dataobj/translator.h:12,
                 from clipboard_w32.cc:18:
dataobj/../tpl/hashtable_tpl.h: In member function 'bool hashtable_tpl<key_t, value_t, hash_t>::is_contained(key_t) const':
dataobj/../tpl/hashtable_tpl.h:230:3: error: need 'typename' before 'for_sel_ref<slist_tpl<hashtable_tpl<key_t, value_t, hash_t>::node_t>, void(const int&)>::ref' because 'for_sel_
ref<slist_tpl<hashtable_tpl<key_t, value_t, hash_t>::node_t>, void(const int&)>' is a dependent scope
dataobj/../tpl/hashtable_tpl.h:230:1: error: expected ';' before 'container___230'
dataobj/../tpl/hashtable_tpl.h:230:3: error: need 'typename' before 'for_sel_iter<slist_tpl<hashtable_tpl<key_t, value_t, hash_t>::node_t>, void(const int&)>::iter' because 'for_se
l_iter<slist_tpl<hashtable_tpl<key_t, value_t, hash_t>::node_t>, void(const int&)>' is a dependent scope
dataobj/../tpl/hashtable_tpl.h:230:1: error: expected ';' before 'iter__230'
dataobj/../tpl/hashtable_tpl.h:230:1: error: 'iter__230' was not declared in this scope
dataobj/../tpl/hashtable_tpl.h:230:1: error: 'end__230' was not declared in this scope
dataobj/../tpl/hashtable_tpl.h:230:3: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Iterator> struct std::iterator_traits'
dataobj/../tpl/hashtable_tpl.h:230:3: error:   expected a type, got 'for_sel_iter<slist_tpl<hashtable_tpl<key_t, value_t, hash_t>::node_t>, void(const int&)>::iter'
dataobj/../tpl/hashtable_tpl.h:230:3: error: expected initializer before 'const'
dataobj/../tpl/hashtable_tpl.h:232:4: error: duplicate 'const'
dataobj/../tpl/hashtable_tpl.h:232:31: error: 'iter' was not declared in this scope
make: *** [build/default/clipboard_w32.o] Error 1


I should be grateful for any ideas as to how to deal with this.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

Imho you should use the FORT macro at tpl/hashtable_tpl.h:230 (instead of FOR).
Parsley, sage, rosemary, and maggikraut.

jamespetts

Thank you - that is helpful. I found and fixed a few more compile errors, too, and now have managed to get it to compile.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Vonjo

If you get:
error: unrecognized command line option '-mno-cygwin'
...try to remove -mno-cygwin from Makefile.
It sounds like GCC 4.7.0 has finally removed the deprecated -mno-cygwin option.

Ters

Are there still any versions of mingw out there that actually does use cygwin when this argument is missing? I can't ever remember having used it all these ten-or-so years I've used mingw, despite being aware of its existience, and the executables I get don't seem to have been cygwin-ish.