Skip to main content
Topic: How to compile Simutrans (&Makeobj) on Windows with MSVC (Read 86406 times) previous topic - next topic

How to compile Simutrans (&Makeobj) on Windows with MSVC

Note in 2016: This is now too old (16-8 = 8 years!). You can glean some helpful things from this, but don't expect anything to work as described here. Sorry.

Note: This is now a bit old. I have updated the text & files as possible, but MSVC 2010 has a bit different menus and I don't have (now) access to computer with it. Keep telling me to fix this :P

It is quite easy - I almost feel sorry to spare you from recompiling dependencies with GCC and such jokes. Well, real hackers don't have to follow :D

I don't know if this works for 64bit OSes.

I omitted restarting system, you'll have to do so probably twice.

1 ) Download Microsoft Visual C++ - for free,
2 ) install it.
3 ) Download precompiled libraries for OpenTTD - follow link with highest number, then download the zip file with binary data; its name might include win and should not contain source or ***sum.
4 ) Unpack this zip file somewhere - as an example, C:\example\ottd_libs. Inside this folder you should have a bunch of folders, namely win32 and shared.
5 ) From Dwachs' post, download header and libary and unpack the zip. The .h file goes to shared/include and .lib to win32/library.
6 ) Get the [ftp=ftp://sourceware.org/pub/pthreads-win32/]pthreads library for Win32[/ftp]. From the folders select the one with highest prebuilt-dll-x-y-z-release number. You should know now where the lib and h files go ...
Important: You need the DLL. Put it where your pak folders are!
7 ) Start MSVC and in menu, go to options (tools->options), a window opens with another set of choices to the left, you want to change directories (projects and solutions->VC++ Directories);
8 ) the dropdown menu in the top-right corner (it says Executable files at first) - set it to include files and add to list folder shared/include from the downloaded archive - example, C:\example\shared\include.
9 ) Do the same with library files - add there win32/library - example C:\example\win32\library.

Now you're set up for compiling - but don't have the sources!

10) Install Tortoise SVN (it integrates into Explorer).
11) Create new folder - eg. simutrans_src.
12) Click on it with right mouse button - choose SVN Checkout. A window pops up.
13) URL is svn://servers.simutrans.org/simutrans - Leave the other options be, they're all correct.
14) OK!
15) If asked for p****word, enter user anon and leave p****word empty.
16) Downloading…

(Alternatively you can use the command line svn - that is not material for this guide as it's aimed for click-and-go solution)

And now - Christamaaaaas!

17) In the folder downloaded from svn (maybe simutrans_src) go to simutrans\trunk - you can see the lot of source files.
18) Open file simutrans.vcproj.
19) It is from older version, you have to go through wizard for project file update. Again no need to change any settings.
20) Once this is completed, to the left should appear some stuff (Solution Simutrans blah blah). In menu, choose Build->build solution.
21) Waiting…
22) Simutrans executable appears in folder debug (inside the folder with sources is folder Debug).

If you want to run simutrans from MSVC for debugging, you need to change the project properties -> debug
THe command line needs to start with -use_workdir and the working directory should point to the simutrans folder than contains your pak-folders (and the DLL).

Enjoy!


EDIT: The above will always work. Below depends on updated attachments. Thus if this does not work, use the above way.

You can save yourself the trouble with steps 17-18 and use the attached project files. They go to trunk/MSVC2k8/*.* - in other words, in folder trunk you should have a folder MSVC2k8 and in it some files. This is on purpose, so that you don't overwrite any files tracked by svn.

When they are outdated, post here and demand new.

EDIT: instead of attachment, link:
http://vs.simutrans.com/misc_files/simu-MSVC2k8.zip

EDIT: Added pthreads. Corrected ftp link.

EDIT2: For r7808 onwards you need to set the "character set" in "properties->general" to "undefined" or "no set" and not Unicode (depending on your interface langauage).

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!

Re: How to compile Simutrans on Windows with MSVC

Reply #1
cool!! Some people asked me about how to apply the overtaking patch in windows, and I even know how to compile Simutrans in windows. Is there any possiblity that somebody can explain how to apply a patch in windows?

P.S: I guess it's based on the wiki info, isn't it? In that case I think we might consider that everything is right and clear. Unless, until I try and fail... :D

Re: How to compile Simutrans on Windows with MSVC

Reply #2
There is some info on wiki? I missed that :O

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!


Re: How to compile Simutrans on Windows with MSVC

Reply #4
Aha. So there is something at all on wiki. Interesting… thanks to whoever started putting it back into shape!

As to patches - well that can be done via Tortoise, too, but honestly no idea how it goes, I never tried it.

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!

Re: How to compile Simutrans on Windows with MSVC

Reply #5
I think that was thanks to Stormoog or Whoami effort. In reference to applying patches using TortoiseSVN, I've found this tutorial and this thread from TT-forums. It seems very easy so I'll try it later.... :)

Re: How to compile Simutrans on Windows with MSVC

Reply #6
Only for the information:

If you have a big patch, and is the patch testet, I could make every time a spezial run of the nightly-Server!

But not for every "little" pach  8)
I hope you understand my English

Re: How to compile Simutrans on Windows with MSVC

Reply #7
I know. In fact, most of the requests were about the famous overtaking fun patch but as it's still under development and the nightly that included that patch is not available, people ask about how to apply that patch to Simutrans.

P.S: Does it mean that we might do requests for special nightlies?  ::)

Re: How to compile Simutrans on Windows with MSVC

Reply #8
In the last nightly is the overtaking patch .. or???

When you send me a Mail I can make a "spezial run"

I hope you understand my English

Re: How to compile Simutrans on Windows with MSVC

Reply #9
Well, If I remember correctly, the last nightly that included that patch was 2008-09-15_v100.1_r2022-overpatchV7, wasn't it?

Re: How to compile Simutrans on Windows with MSVC

Reply #10
In the SVN log of the code:
Code: [Select]
28.09.2008 ADD: (isidoro/prissi) overtaking for road vehicles/citycars

so since 28.09.2008 is the patch in the code ....
I hope you understand my English

Re: How to compile Simutrans on Windows with MSVC

Reply #11
cool! thanks for the info, wernieman.

Re: How to compile Simutrans on Windows with MSVC

Reply #12
I'm trying to write a series of articles for the blog with the title: Dive in Simutrans (python guys will get it..;)) They're all in spanish, and one of them is just a translation on VS post above with some extra details, but I might translate them to EN and compile all of them in a short guide, lets call it Simutrans Compiling Guide or Dive in Simutrans. Perhaps this encourage people to take part in the code development, what do you think?

Re: How to compile Simutrans on Windows with MSVC

Reply #13
Of course! I thought about posting this for about a second - and then of course put it here. It helps people get started, so why not.

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!

Re: How to compile Simutrans on Windows with MSVC

Reply #14
Ok, so I'll translate them. This is the list of articles (in spanish) that are available at this moment in the blog Escala Real:

Only miss another one about how to create a piece of code and add it to simutrans sources, but as I'm not an expert on that, I'll need help from somebody who has more experience dealing with those issues. Anyway, I think with these three articles it's enough to encourage people to code something for Simutrans.

I'm going to finish this post with two programming quotes:
“Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots.  So far the Universe is winning.”
(Rich Cook)

“First learn computer science and all the theory.  Next develop a programming style.  Then forget all that and just hack.”
(George Carrette)


Re: How to compile Simutrans on Windows with MSVC

Reply #15
While I can agree to some degree with the first I certainly cannot agree with the second. I am doing the reverse and trust me, with the (for me) modern abstract object oriented concepts, first knowing what one is doing makes hacking easier. I mean I main self-taught programming in the early 80ies with book from the mid 70ies -- no OOP at all.

Re: How to compile Simutrans on Windows with MSVC

Reply #16
[...]
Only miss another one about how to create a piece of code and add it to simutrans sources, but as I'm not an expert on that, I'll need help from somebody who has experience more experience dealing with those issues.
[...]

If I can be of any help, please tell, although I left the dark side of the Force long time ago (two years or so)...

In fact, there is not much to it.  My weapons are:
  • A good text editor (kate)
  • A good compiler/debugger couple (gcc/gdb)
  • A search tool (grep)
  • A good versioning tool (which better than svn itself?)
  • A web-translator from German (like Google's)
  • Lots of sticky notes

With the debugger, one can figure out the variables and functions used for something, then one can inspect the code and then modify, and try.  Once done, generating the patch is very easy.  Simutrans code is well documented and easy to follow, imho, but the language is a problem for non-German speakers like me...

While I can agree to some degree with the first I certainly cannot agree with the second. I am doing the reverse and trust me, with the (for me) modern abstract object oriented concepts, first knowing what one is doing makes hacking easier. I mean I main self-taught programming in the early 80ies with book from the mid 70ies -- no OOP at all.

I certainly belong to The Low-level Lonely Hearts Club Band...

 

Re: How to compile Simutrans on Windows with MSVC

Reply #17
Here are updated project files for this ide.

Unpack this so that you get folder trunk/MSVC2k8 and there the files (sln and vcproj) (with this you can skip steps O,P,Q).

EDIT: removed and added to first post.

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!

Re: How to compile Simutrans on Windows with MSVC

Reply #18
@VS: thank you for this nice introduction. The Windows-Zip-extraction program refuses to extract the libs-files and I had to do this by hand ???
Parsley, sage, rosemary, and maggikraut.

Re: How to compile Simutrans on Windows with MSVC

Reply #19
Strange. Well if you got it to work anyway, congrats! :)

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!

Re: How to compile Simutrans on Windows with MSVC

Reply #20
Which do y'all recommend downloading, Visual C++ 2005 or 2008?

Re: How to compile Simutrans on Windows with MSVC

Reply #21
I suppose it doesn't matter but I used the latest version (2008)

Re: How to compile Simutrans on Windows with MSVC

Reply #22
I hear everyone (elsewhere) say 2005 was the last good version... but I just wanted something and grabbed the first thing I saw.

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!

Re: How to compile Simutrans on Windows with MSVC

Reply #23
OK, thanks fellas.  I've got a trial version of 2005 now, (it came with a game tut I bought).  Prior to that I had used the toolkit to compile for mods for Civ.  Since I'm kinda familiar with 2005, I'll probably download it.

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #24
Updated project files for latest additions...

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!

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #25
Now simutrans needs an additional library: bzlib. Here are header and lib-files. Put them in your include/library directories.
Parsley, sage, rosemary, and maggikraut.

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #26
And since those are open source: http://www.bzip.org/ with the source ...

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #27
Hello:

I have tried to compile the code following the instructions, but it does not generate the feasible one. It appears 62 errors and approximately 1000 warnings, but it does not create the programme. My system is Windows 7 x64 and I use Visual C ++ 2008.
I have put bzip files.

Regards and thanks.


Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #28
If you give us the output of your compiling-test, whe COULD help ....
I hope you understand my English

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #29
The disadvantage is that it is in Spanish some parts.


Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #30
1. could you make a new thread
2. sorry, but when i decompress your log then it is empty :o(
I hope you understand my English

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #31
1.Thanks
2.Sorry, I will upload the file to other server.

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #32
I am having some trouble compiling Simutrans-Experimental with the new network module - I am wondering whether there is something specific to Simutrans-Experimental that is causing the problem, or whether I am doing something wrong more generally. Here is the output that I get, with numerous linker errors:

Code: [Select]
1>Linking...
1>simworld.obj : error LNK2019: unresolved external symbol _send@16 referenced in function "public: bool __thiscall karte_t::laden(char const *)" (?laden@karte_t@@QAE_NPBD@Z)
1>network.obj : error LNK2001: unresolved external symbol _send@16
1>network.obj : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function "bool __cdecl network_initialize(void)" (?network_initialize@@YA_NXZ)
1>network.obj : error LNK2019: unresolved external symbol _connect@12 referenced in function "char const * __cdecl network_open_address(char const *,unsigned int &)" (?network_open_address@@YAPBDPBDAAI@Z)
1>network.obj : error LNK2019: unresolved external symbol _socket@12 referenced in function "char const * __cdecl network_open_address(char const *,unsigned int &)" (?network_open_address@@YAPBDPBDAAI@Z)
1>network.obj : error LNK2019: unresolved external symbol _htons@4 referenced in function "char const * __cdecl network_open_address(char const *,unsigned int &)" (?network_open_address@@YAPBDPBDAAI@Z)
1>network.obj : error LNK2019: unresolved external symbol _inet_addr@4 referenced in function "char const * __cdecl network_open_address(char const *,unsigned int &)" (?network_open_address@@YAPBDPBDAAI@Z)
1>network.obj : error LNK2019: unresolved external symbol _listen@8 referenced in function "bool __cdecl network_init_server(int)" (?network_init_server@@YA_NH@Z)
1>network.obj : error LNK2019: unresolved external symbol _bind@12 referenced in function "bool __cdecl network_init_server(int)" (?network_init_server@@YA_NH@Z)
1>network.obj : error LNK2019: unresolved external symbol _htonl@4 referenced in function "bool __cdecl network_init_server(int)" (?network_init_server@@YA_NH@Z)
1>network.obj : error LNK2019: unresolved external symbol _recv@16 referenced in function "unsigned int __cdecl network_check_activity(int,char *,int &)" (?network_check_activity@@YAIHPADAAH@Z)
1>network.obj : error LNK2019: unresolved external symbol _inet_ntoa@4 referenced in function "unsigned int __cdecl network_check_activity(int,char *,int &)" (?network_check_activity@@YAIHPADAAH@Z)
1>network.obj : error LNK2019: unresolved external symbol _accept@12 referenced in function "unsigned int __cdecl network_check_activity(int,char *,int &)" (?network_check_activity@@YAIHPADAAH@Z)
1>network.obj : error LNK2019: unresolved external symbol ___WSAFDIsSet@8 referenced in function "unsigned int __cdecl network_check_activity(int,char *,int &)" (?network_check_activity@@YAIHPADAAH@Z)
1>network.obj : error LNK2019: unresolved external symbol _select@20 referenced in function "unsigned int __cdecl network_check_activity(int,char *,int &)" (?network_check_activity@@YAIHPADAAH@Z)
1>network.obj : error LNK2019: unresolved external symbol _closesocket@4 referenced in function "void __cdecl network_close_socket(unsigned int)" (?network_close_socket@@YAXI@Z)
1>network.obj : error LNK2019: unresolved external symbol _WSACleanup@0 referenced in function "void __cdecl network_core_shutdown(void)" (?network_core_shutdown@@YAXXZ)
1>..\simutrans-experimental-binaries\Simutrans-Experimental-debug.exe : fatal error LNK1120: 16 unresolved externals

Have others experienced those errors, or do they seem specific to Simutrans-Experimental?
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.

Re: How to compile Simutrans (&Makeobj) on Windows with MSVC

Reply #33
It was caused by the missing reference to wsock32.lib in the project file. James has fixed it by now.