News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

How to compile Simutrans Experimental

Started by Michael Hauber, June 06, 2013, 02:39:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Michael Hauber

I'd guess its as per this thread and have tried to follow the instructions, but get stuck at step 3.  The link to OTTD libraries gives me a blank web page (not an error), so I guess the files are either temporarily or permanently moved elsewhere by the OTTD folks.  Are these needed for experimental as well?  Can I get them elsewhere?  Does someone need to update the compiling simutrans thread?

neroden

Quote from: Michael Hauber on June 06, 2013, 02:39:18 AM
Can I get them elsewhere?
You don't need any OTTD-specific libraries; this is just a list of libraries.  Someone should write down the correct list.
Quote
Does someone need to update the compiling simutrans thread?

I believe someone should update the "compiling simutrans" thread. 

I compile on Linux: on Linux, the crucial libraries are:
zlib (also known as libz)
libbz2
SDL
sdl_mixer

On Windows, I know you still need libbz2.  You need an equivalent for zlib, but I think one comes with Windows.  You apparently need pthreads.  You also need GDI (instead of SDL), but that comes with Windows.  I couldn't tell you for sure what else you need (I stopped using Windows over 10 years ago), but this seems to be James's list from his vcxproj file:
kernel32.lib;user32.lib;gdi32.lib;winmm.lib;zlibstat.lib;advapi32.lib;wsock32.lib;libbz2.lib;Strmiids.lib;Ws2_32.lib;shell32.lib;pthreadVCE2.lib
It looks like you don't need pthreads if you compile with the single-threaded option (logical,that).  Some of the others may also be optional.

VS

You already listed all external dependencies - the rest is windows api and comes with the compiler (I hope).

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Michael Hauber

I'm now stuck trying to get zlib linked correctly (I think).  I was getting an 'unable to open zlib.h' error, and  I downloaded the zlib dll from the zlib web page at http://zlib.net/ and followed the instructions in the included usage.txt to add the files zlib.h, zconf.h and zdll.lib to my include/lib directories, and then to link zdll.lib to the project.  Once I've done this I get an error 'unable to open zlibstat.lib', which is not a file available in the zlib128-dll.zip file for windows that I downloaded.  If I delete the link to this file I get a bunch of further errors, so evidently I need it.

jamespetts

Is zlibstat.lib in your libraries include directory?
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.

Michael Hauber

That file does not seem to exist anywhere on my computer.

jamespetts

That is probably the problem, in that case.
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.

Michael Hauber

So how do I get the file?  The best I come up with on google is to compile zlib myself at http://www.helyar.net/2010/compiling-zlib-lib-on-windows/

I follow the instructions, but have MS studio 2012 instead of 2010, and its version 1.28 of zlib currently available, not 1.24.  I try compiling and get multiple link errors, and 5 of the 6 files fail, but the one that succeeds is zstat.lib, so I try copying it to my library folder and recompiling simutrans.  This now gives me these errors:

1>------ Build started: Project: Simutrans-Experimental, Configuration: Debug Win32 ------
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _memchr already defined in LIBCMTD.lib(memchr.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _strerror already defined in LIBCMTD.lib(strerror.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __errno already defined in LIBCMTD.lib(dosmap.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __close already defined in LIBCMTD.lib(close.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __read already defined in LIBCMTD.lib(read.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __write already defined in LIBCMTD.lib(write.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _wcstombs already defined in LIBCMTD.lib(wcstombs.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __lseeki64 already defined in LIBCMTD.lib(lseeki64.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __open already defined in LIBCMTD.lib(open.obj)
1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __wopen already defined in LIBCMTD.lib(wopen.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>.\simutrans\Simutrans-Experimental-debug.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

jamespetts

Hmm - this is a little perplexing. It looks as though you have doubled up on a library somewhere - you could try excluding libraries one by one until you no longer get these errors? Sorry not to be able to be of greater help here.
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.

Michael Hauber

#9
These errors are new since I compiled the zlibstat.lib file.  Does that mean the double up is with this file, and that perhaps I compiled it wrong?  Or the errors could have been there before and it was only when I added this file that the compiler went far enough to find these errors?

Edit:  Or I can read the errors and find that the libraries with the conflict are MSVCRTD and LIBCMTD?  Which are both apparently default libraries supplied with visual studio.  But how could they be conflicting for me but not everyone else??

Edit:  If I exclude MSVCRTD from the default libraries to search, then zlibstat.lib has unresolved references.  If I instead exlcude LIBCMTD then simsys_w.obj in simutrans has unresolved references.

Markohs

Try with this libs, Michael, I have no problems using them.

In case of doubt re-create the project again, you might have touched some setting you shoudn't.

https://dl.dropboxusercontent.com/u/30024783/simulibs.zip

I unpack it in c:\code , include dirs are:

C:\code\bzip2;C:\code\zlib-1.2.5;C:\code\pthreads\pthreads.2

linker->input->additional dependences:

kernel32.lib;user32.lib;gdi32.lib;shell32.lib;winmm.lib;zlibstat.lib;advapi32.lib;ws2_32.lib;libbz2.lib;pthreadVC2.lib

linker -> general->additional library Dependencies:

C:\code\pthreads\Pre-built.2\lib;C:\code\zliball\static32;C:\code\bzip2


Aboyut your build: Sounds to me the project settings you used when compiling zlib are not the same than the ones you use in simutrans, might be debug vs release, sifferent memory model, signarures... Can be a lot of ****, try with my libraries and a fresh project to be sure.


C/C++ -> Preprocessor definitions: NOMINMAX=1;ZLIB_WINAPI;REVISION_FROM_FILE;LITTLE_ENDIAN;DEBUG=3;COLOUR_DEPTH=16;%(PreprocessorDefinitions)

Defining ZLIB_WINAPI is *mandatory*, or the linking will fail.

Michael Hauber

I have now got it to work.  Trouble seemed to be that I'd compiled the zlibstat.lib library in debug mode instead of release mode.  Curiously enough I still get a SAFESEH error for this library, and google tells me this is when you link to a library compiled in a previous version of studio, that the error can be ignored by turning of the SAFESEH checking option in linking options but this should not be done as a 'CRT version incompatability can byte'.  I turned it off anyway and I can compile an exe that works.

Next to decide what to try and tinker with.....