News:

SimuTranslator
Make Simutrans speak your language.

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

Started by VS, October 20, 2008, 08:27:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

Project files in first post are outdated. Could you upload updated versions?
Parsley, sage, rosemary, and maggikraut.

prissi


HDomos

Quote from: VS on October 20, 2008, 08:27:42 AM

6 ) 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);
7 ) 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.
8 ) Do the same with library files - add there win32/library - example C:\example\win32\library.


In Microsoft Visual Studio 11 you cant do this (menu structure change as you wrote).
Instead you can do this:

In the menu open Project>Simutrans properties
In the popping window, go Configuration Properties>VC++ Directories
There you can specify the include and the library directories

VS

This thread needs an overhaul replacement... :( Has it really been 4 years?

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!

hreintke

LS,

Followed the procedure, downloading and configuring all went OK (I think), used MSVC 2010.
During compile only few warnings but during link I get the error

1>simsys.obj : error LNK2001: unresolved external symbol __imp__ShellExecuteExA@4

Did anyone see this too and/or know how to resolve this ?

Kind regards,

Herman

Dwachs

Parsley, sage, rosemary, and maggikraut.

hreintke

Hello Dwachs,

I used both DEBUG and RELEASE build. Both with the same result.

Only difference is an additional warning in debug : 1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification

But also the errormessage : 1>simsys.obj : error LNK2001: unresolved external symbol __imp__ShellExecuteExA@4

Kind regards,

Herman

Dwachs

Maybe you need to add the dependency on the library file shell32.lib.

Would you please post a diff file for the project files if you got it fixed? Then we can update the project file in the repository.
Parsley, sage, rosemary, and maggikraut.

hreintke

Dwachs,

Thanks very much. Adding the shell32.lib to debug and release additional dependencies properties solved it.

I will clean up my config first and then provide the diff. Otherwise everyone might end up with more updates then needed because of my trial and error before finding the solution.

Will come shortly.

Herman

prissi

The MSVC2010 project file is a mess, containing abosulte path and so on, and of course also the makeobj creation is missing. After release I will work on a new one. I rather recommend to import the MSVC 2008 project file as a start.

Spartanis

Quote from: VS on April 08, 2012, 05:26:38 PM
This thread needs an overhaul replacement... :( Has it really been 4 years?

LOL.. I agree.. Im planning to learn MSVC and all that jazz and then fiddle around Simutrans Coding after i done my Pakset, next year or so. I really would LOVE to be part of this team any way i can...

:)

hreintke

LS,

To get a good understanding of msvc/simutrans I also took the way prissi suggested and took the msvc 2008 project file as a start.

That takes me however to a project which doesn't compile because it cannot find pthread.h.
Looked at the include and it is preceded by #if MULTI_THREAD>1 so I could remove the dependency for now by setting the option.

But.. I cannot find the location where to find or put it. In my MinGW there is a file called config.default, but here this must be msvc project configuration specific. Can you help me on this ?

Herman

prissi

YOu have to right click (1) and select project properties. then got to the C++ (2) entry in the tree on the left, then Preprocessor (3). Click on box 4 to see the dialoge.

Lus1531

I had taken source code of r6298 from svn, but I could'nt build using MSVC2010 because "api_gui.cc" has not been added to project.
I hope the development team to update project file.
BattleSimutrans project(Japanese)
In japanese,"Lus" is spelled "ラス".

jamespetts

The link to the pthreads download in the first message is missing a colon, and redirects to a spam page about terminal emulators. The correct link is ftp://sourceware.org/pub/pthreads-win32/.
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.

Lus1531

That link is incorrect same the first message.
Use ftp tags for ftp link,it can be linked.
[ftp]ftp://sourceware.org/pub/pthreads-win32/[/ftp]
ftp://sourceware.org/pub/pthreads-win32/
BattleSimutrans project(Japanese)
In japanese,"Lus" is spelled "ラス".

jamespetts

Ahh - a quirk of the board code! Thank you: that is helpful.
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

Parsley, sage, rosemary, and maggikraut.

Sarlock

Pulling my hair out...

Warning   1   warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification   C:\Program Files (x86)\Simutrans\source code\LINK   Simutrans
Error   2   error LNK2001: unresolved external symbol "void __cdecl export_gui(struct SQVM *)" (?export_gui@@YAXPAUSQVM@@@Z)   C:\Program Files (x86)\Simutrans\source code\export_objs.obj   Simutrans
Error   3   error LNK1120: 1 unresolved externals   C:\Program Files (x86)\Simutrans\source code\Debug\Simutrans.exe   1   1   Simutrans

Stumbled through a host of other problems before and slowly resolved them one by one but this one has stonewalled me.  Having never compiled C++ and never used MVSE (2012) before this is quickly proving to be an exercise in frustration.  And all I want to do is figure out how to install that .diff so that I can test my new landscape tiles that I drew...  :-[
Current projects: Pak128 Trees, blender graphics

hreintke

Sarlock,

Replying without access to my own compile environment so it is from memory.
I think I encountered this when updating my own copy to the latest trunk.

My solution then was to include script/api_gui.cc in the project.

Herman

VS

You're on the right track, if you got so far!

As files are added to code, they're - obviously - missing in the old project file, so there will be a long exercise in finding files to add. You can try the attached project file - it lists everything needed for the program, but you will (probably) have to configure the external libraries again. The folder "msvc2k10" with 3 files belongs under "trunk".

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!

hreintke

LS,

What I mostly do when I get these kind of errors is looking in the updates in the "makefile" on svn.
That lists all necessary sources and is kept up-to-date.

When I see additions or deletions I update my MSVC project accordingly.

Herman

Sarlock

Thanks for the suggestions, I'll try them later when I get some time to attempt it again.

There were several missing/mis-located files that I was able to intercept and place in the libraries, so I am making slow progress.  This one stumped me because it didn't refer to a missing file so I wasn't sure how to proceed.  Hopefully after this issue is resolved I can compile the program and then figure out how to include the .diff file and get back to drawing things :)
Current projects: Pak128 Trees, blender graphics

Dwachs

Quote from: Sarlock on February 22, 2013, 08:30:52 AM
Warning   1   warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification   C:\Program Files (x86)\Simutrans\source code\LINK   Simutrans
Error   2   error LNK2001: unresolved external symbol "void __cdecl export_gui(struct SQVM *)" (?export_gui@@YAXPAUSQVM@@@Z)   C:\Program Files (x86)\Simutrans\source code\export_objs.obj   Simutrans
Error   3   error LNK1120: 1 unresolved externals   C:\Program Files (x86)\Simutrans\source code\Debug\Simutrans.exe   1   1   Simutrans
Please report these errors in the 'Bug reports' section, as these are omissions in the project file.
Parsley, sage, rosemary, and maggikraut.

Max-Max

Hi,

I have downloaded all teh libraries, checked out the trunk from SVN and I added the include and lib paths to the solution.
However, When I build, I get 14 errors and 9 warnings.

Warning   1   warning C4244: 'argument' : conversion from 'sint64' to 'const sint32', possible loss of data   D:\Projects\simutrans\dings\leitung2.cc   514   1   Simutrans
Warning   2   warning C4244: 'argument' : conversion from 'sint64' to 'const sint32', possible loss of data   D:\Projects\simutrans\dings\leitung2.cc   615   1   Simutrans
Warning   3   warning C4244: 'argument' : conversion from 'sint64' to 'const sint32', possible loss of data   D:\Projects\simutrans\dings\leitung2.cc   726   1   Simutrans
Warning   4   warning C4244: 'argument' : conversion from 'float' to 'const int', possible loss of data   D:\Projects\simutrans\gui\welt.cc   364   1   Simutrans
Warning   5   warning C4244: 'argument' : conversion from 'float' to 'const int', possible loss of data   D:\Projects\simutrans\gui\welt.cc   368   1   Simutrans
Warning   6   warning C4244: 'argument' : conversion from 'const sint64' to 'sint32', possible loss of data   D:\Projects\simutrans\player\simplay.cc   136   1   Simutrans
Warning   7   warning C4244: 'return' : conversion from 'sint64' to 'sint32', possible loss of data   D:\Projects\simutrans\player\simplay.cc   455   1   Simutrans
Warning   8   warning C4244: 'argument' : conversion from 'uint16' to 'uint8', possible loss of data   D:\Projects\simutrans\simworld.cc   2474   1   Simutrans
Warning   9   warning C4244: 'argument' : conversion from 'double' to 'const uint32', possible loss of data   D:\Projects\simutrans\simworld.cc   3007   1   Simutrans
Error   10   error LNK2001: unresolved external symbol "unsigned char __cdecl script_api::get_ribi(struct SQVM *,int)" (?get_ribi@script_api@@YAEPAUSQVM@@H@Z)   D:\Projects\simutrans\api_tiles.obj   Simutrans
Error   11   error LNK2001: unresolved external symbol "int __cdecl script_api::push_ribi(struct SQVM *,unsigned char)" (?push_ribi@script_api@@YAHPAUSQVM@@E@Z)   D:\Projects\simutrans\api_tiles.obj   Simutrans
Error   12   error LNK2001: unresolved external symbol "public: enum waytype_t __thiscall weg_besch_t::get_finance_waytype(void)const " (?get_finance_waytype@weg_besch_t@@QBE?AW4waytype_t@@XZ)   D:\Projects\simutrans\bruecke.obj   Simutrans
Error   13   error LNK2001: unresolved external symbol "void __cdecl export_simple(struct SQVM *)" (?export_simple@@YAXPAUSQVM@@@Z)   D:\Projects\simutrans\export_objs.obj   Simutrans
Error   14   error LNK2001: unresolved external symbol "public: __int64 __thiscall finance_t::get_maintenance_with_bits(enum transport_type)const " (?get_maintenance_with_bits@finance_t@@QBE_JW4transport_type@@@Z)   D:\Projects\simutrans\money_frame.obj   Simutrans
Error   15   error LNK2001: unresolved external symbol "public: void __thiscall finance_t::calc_finance_history(void)" (?calc_finance_history@finance_t@@QAEXXZ)   D:\Projects\simutrans\money_frame.obj   Simutrans
Error   16   error LNK2001: unresolved external symbol "public: void __thiscall finance_t::update_assets(__int64,enum waytype_t)" (?update_assets@finance_t@@QAEX_JW4waytype_t@@@Z)   D:\Projects\simutrans\simplay.obj   Simutrans
Error   17   error LNK2001: unresolved external symbol "public: static enum transport_type __cdecl finance_t::translate_waytype_to_tt(enum waytype_t)" (?translate_waytype_to_tt@finance_t@@SA?AW4transport_type@@W4waytype_t@@@Z)   D:\Projects\simutrans\simplay.obj   Simutrans
Error   18   error LNK2001: unresolved external symbol "public: void __thiscall finance_t::set_assets(__int64 const (&)[11])" (?set_assets@finance_t@@QAEXAAY0L@$$CB_J@Z)   D:\Projects\simutrans\simplay.obj   Simutrans
Error   19   error LNK2001: unresolved external symbol "public: void __thiscall finance_t::rdwr(class loadsave_t *)" (?rdwr@finance_t@@QAEXPAVloadsave_t@@@Z)   D:\Projects\simutrans\simplay.obj   Simutrans
Error   20   error LNK2001: unresolved external symbol "public: void __thiscall finance_t::new_month(void)" (?new_month@finance_t@@QAEXXZ)   D:\Projects\simutrans\simplay.obj   Simutrans
Error   21   error LNK2001: unresolved external symbol "public: __thiscall finance_t::finance_t(class spieler_t *,class karte_t *)" (??0finance_t@@QAE@PAVspieler_t@@PAVkarte_t@@@Z)   D:\Projects\simutrans\simplay.obj   Simutrans
Error   22   error LNK2001: unresolved external symbol "public: bool __thiscall finance_t::is_bancrupted(void)const " (?is_bancrupted@finance_t@@QBE_NXZ)   D:\Projects\simutrans\simworld.obj   Simutrans
Error   23   error LNK1120: 13 unresolved externals   D:\Projects\simutrans\Release\Simutrans.exe   Simutrans


As you can see, the the Linker is complainnig about function names that doesn't exist. I have done a solution wide search for these functions and they don't seem to be anywhere.

I'm using VC2013 Express. Has someone managed to build this solution?!?

PS. Who came up with the brilliant idea to mix files and function names in German/English for an international open project?!? :P
- My code doesn't have bugs. It develops random features...

Ters

Looks like player/finance.cc hasn't been added to the project.

Quote from: Max-Max on April 07, 2013, 04:06:33 PM
PS. Who came up with the brilliant idea to mix files and function names in German/English for an international open project?!? :P

The alternative would have been to have it all in German. Simutrans was born a German, but is slowly becomming English to open up for international developers, hence the mix. The progress is slow, in part because translation is rather boring and in itself unproductive, unlike bug hunting and making new features. And in part because a massive (automated) translation could ruin the code, or at best make it unrecognizable to seasoned developers. It's a chicked and egg scenario, the German code restricts the number of developers, and the low number of developers restrict the speed of translation.

IgorEliezer

Quote from: Ters on April 07, 2013, 04:38:53 PMIt's a chicken and egg scenario, the German code restricts the number of developers, and the low number of developers restrict the speed of translation.
Yep. Once in a while, some people submit patches that translate parts of code, but it's a slow process for the reasons that Ters already pointed out, the developers need to agree on terminologies and styles that are used throughout the code.

But still, feel free to ask for support. Depending on the case, it could be a new reason to translate more parts of the code.

Max-Max

Thank you for the quick response.

Yes, the player/finance.cc was missing from the project, but there are still some unresolved links left. I also found out that script/api/api_simple.cc was also missing in the project. I have to run away now but I need help to locate the last issue...

Error13   error LNK2001: unresolved external symbol "public: enum waytype_t __thiscall weg_besch_t::get_finance_waytype(void)const " (?get_finance_waytype@weg_besch_t@@QBE?AW4waytype_t@@XZ)   D:\Projects\simutrans\bruecke.obj   Simutrans

PS. The German/English comment was more an reflection when I browsed through the code =) I suspected it had started as a German project. Well as the Amercans say: We are converting to the metric system, Inch by Inch.... :)
- My code doesn't have bugs. It develops random features...

Dwachs

Parsley, sage, rosemary, and maggikraut.

Max-Max

Thank you, now it goes through the build process (Release) and I have copied the pthreads-w32-x-x-x-release dll's to the Release folder.

I'm running Win7 x64 and when I start my simutrans.exe a little dialog just flashes and nothing else happens.
If I start it from VC2013 Express The log shows that it can't find a bunch of DLL's...

'Simutrans.exe' (Win32): Loaded 'D:\Projects\simutrans\Release\Simutrans.exe'. Symbols loaded.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nsi.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'D:\Projects\simutrans\Release\pthreadVC2.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr100.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\apphelp.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\AppPatch\AcLayers.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\userenv.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\profapi.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winspool.drv'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mpr.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'Simutrans.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll'


So I guessed that it needs the folder structure to work. I copied my simutrans.exe into my simutrans installation. It complained about pthreadVC2.dll not being present and there was a pthreadGC2.dll in the folder.

I copied over the pthreadVC2.dll and my simutrans.exe worked fine =)

Question:
Has pthreadGC2.dll been replaced by pthreadVC2.dll?
What is SDL.dll? It was not mentioned in the list of needed precompiled libraries and my new simutrans.exe works fine without it.

EDIT:
I was to fast to shout Hurray!! I managed to start my simutrans ONCE, thereafter I noticed that the config file had changed and after that I can't start my version of simutrans. I get the message: "The appllication was unable to start correctly (0xc000007b)..."

Is there some sensitive path information that has to be configured?
- My code doesn't have bugs. It develops random features...

VS

1) "Cannot find or open the PDB file" = can't debug code of that DLL. Note that the DLLs themselves were "Loaded", so that's all good...

2) pthread*C2.dll: G -> MingGW; V -> Microsoft (I think)

3) The config file - you mean settings.xml? It shouldn't contain any path information.

However!
You can easily debug your compiled simutrans without copying files and whatnot. Simply set in project properties / debugging (preferably for all configurations): command arguments "-use_workdir" and working directory [your normal Simutrans install]. See attached picture...

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!

Max-Max

I turned on the remote server PDB to get them and they all loads fine, just as you stated.
Unfortunately, simutrans crash before the debugger has any chance to stop the process (I start the debug process with F11, trace into).

After some sniffing around it seems like the error 0xc000007b is caused by a faulty image file. Some information also indicates that this problem may occurs when a 32bit application loads a 64bit DLL. But it is also said that Windows prevents a 32bit app to load any 64bit DLL:s...

I wonder if the pre-compiled library files are up to date or incompatible with this version of Simutrans. It seems like the Wiki isn't in synch with the current version (lots of broken pages) so I'm not sure if I have the right versions.

libbz2.zip - ‎2009-‎11-‎14 ‏‎21:01
openttd-useful-4.2-win.zip
pthreads-w32-2-9-1-release.zip

Is there any reason to not have the pre-compiled libraries in the repository, or include the source for them as sub projects?

I have the full license of GarageGames's Torque 2D and 3D engines and they have included all the source for the external libraries matching the game engine version. It works as a charm!
- My code doesn't have bugs. It develops random features...

prissi

Licence issues, as libaries are under different licence than simutrans. Furthermore, x64 programs can call 32 bit dlls on windows. Moreover, MSVC12 cannot even built 64 bit binaries. Was this changed in 13?

But most importantly for debugging:
Do NOT copy the executable. Set the simutrans main installation path in the debuggers as show by VS. Add "-debug 3 -use_workdir " as parameters. This should start a debugging session. I work like this all the time.

Markohs

In my experience is better to copy the executable and execute there when debugging.

I have a c:\simutrans folder with a normal simutrans installation and all paks I require there, and in the project (right-click properties build events post-build events) I have:

copy "$(OutDir)\$(TargetFileName)" "c:\simutrans"

Then in "debugging", command I have : c:\simutrans\$(TargetFileName) and Working directory c:\simutrans

Works for me, as prissi said you can also add -debug, I don't use -workdir, because I copy it there.

Both prissi's option and mine should work with no problems.

I recently installed VS 2013 and I have no problems compiling, just had to disable linker/advanced/Image Has SafeException Handlers: NO . This is because my linked libraries (SDL, libz etc.. ), have been compiled using an older VS compiler (I downloaded most of them from the internet pre-built), if you compile yourself you should be able to use SAFESEH, but who cares.

EDIT: One last tip: If you are going to debug a lot I advise you do disable the pre-build event, that changes the version nomber and forces re-compiling a few files each time.

Max-Max

None of this helped. I start to believe that either I'm a complete idiot or that something is wrong with my installation. During my last post I hadn't slept for 20 hours. I will remove simutrans source and start over fresh, maybe even reinstall VC++.

I would be really happy if you guys could zip your project file and static libraries for me, so we can exclude them from the equation.
Thank you all, I really appreciate your patience with me...

PS. I was wrong, I had VC2012 not 2013, maybe I should install 2013 instead?
- My code doesn't have bugs. It develops random features...