The International Simutrans Forum

 

Author Topic: Compiling the SDL version in Windows  (Read 8344 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Compiling the SDL version in Windows
« on: May 09, 2009, 02:14:28 PM »
How does one compile the SDL version of Simutrans under Windows?

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Compiling the SDL version in Windows
« Reply #1 on: May 09, 2009, 05:44:07 PM »
Perhaps with cygwin? It's a Linux-like environment for Windows that makes possible to port software running on POSIX systems (such as Linux, BSD, and Unix systems) to Windows.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #2 on: May 09, 2009, 05:55:42 PM »
How would I go about setting that up?

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Compiling the SDL version in Windows
« Reply #3 on: May 09, 2009, 07:10:31 PM »
You could probably dive into depths of mingw and makefiles and all that nastiness. IIRC prissi uses cygwin+mingw... but better wait for someone [other than me] who knows what he talks about.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10669
  • Languages: De,EN,JP
Re: Compiling the SDL version in Windows
« Reply #4 on: May 09, 2009, 07:49:01 PM »
Mingw or MSVC++. Have a look at the official SDL-pages, they have a version for MSVC too ... You need then include SDL_sound and simsys_s.cc. (I haven't tried this with MSVC but i should work ... )

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #5 on: May 09, 2009, 08:15:28 PM »
Ahh, I have tried with MSVC++, and it doesn't work - I get the following errors:

Code: [Select]
1>simsys_s.cc
1>.\simsys_s.cc(678) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>.\simsys_s.cc(682) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Any idea how to resolve them?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10669
  • Languages: De,EN,JP
Re: Compiling the SDL version in Windows
« Reply #6 on: May 09, 2009, 08:26:55 PM »
Cast them or switch off error 2664. Or better use MessageBoxA, since the strings will be ASCII anyway ...

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #7 on: May 09, 2009, 08:35:50 PM »
Prissi,

thank you very much. I switched to MessageBoxA, but then got this error:

Code: [Select]
1>simsys_s.obj : error LNK2019: unresolved external symbol _dr_screenshot_png referenced in function "int __cdecl dr_screenshot(char const *)" (?dr_screenshot@@YAHPBD@Z)
1>Debug (SDL)\Simutrans-Experimental-SDL.exe : fatal error LNK1120: 1 unresolved externals

Any ideas?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10669
  • Languages: De,EN,JP
Re: Compiling the SDL version in Windows
« Reply #8 on: May 09, 2009, 08:42:57 PM »
add also dr_scr4eenshot_w32.c to your makefile?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #9 on: May 09, 2009, 08:58:02 PM »
Prissi,

sorry if this is a silly question - but where would I find dr_scr4eenshot_w32.c?

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Compiling the SDL version in Windows
« Reply #10 on: May 09, 2009, 09:38:05 PM »
James, the file is called simsys_w32_png.c and I was able to locate it after some rather rudimentary searches. Although, the difference might be that I knew from previous rummaging through code that the libraries' bindings are mostly in simsys_*files.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #11 on: May 10, 2009, 10:58:14 AM »
VS,

that can't be right: that file is already included in the project, and it is a GDI file. The very top has the following code:

Code: [Select]
#ifndef WIN32
#error "Only Windows has GDI+!"
#endif

// windows Bibliotheken DirectDraw 5.x
#include <windows.h>

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Compiling the SDL version in Windows
« Reply #12 on: May 10, 2009, 01:55:03 PM »
Still, it is the file containing implementation of dr_screenshot_png. I don't see anything else in it, so it might be safe to assume it's what you need and - just go ahead and try...? Although there might be some problem with leading underscore? It (the first _) isn't anywhere in my version of sources.

FWIW, saving as png can be done by linking to either libpng, or any other library (capable of that feat), which is in this case gdi+. So it's just for saving the picture, not as the whole backend. Or at least it seems so to me.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #13 on: May 10, 2009, 02:56:37 PM »
VS,

ahh, you were right: enabling that did let it compile. It was somewhat confusing - I thought that it was a GDI implementation. However, now, I have another problem: as soon as it starts, it immediately exits again, with a code of -1:

Code: [Select]
'Simutrans-Experimental-SDL.exe': Loaded 'F:\My Documents\Development\Simutrans\simutrans-experimental-sources\Debug (SDL)\Simutrans-Experimental-SDL.exe', Symbols loaded.
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\Program Files\mlt\bin\SDL.dll', Binary was not built with debug information.
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\winmm.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\Program Files\Kaspersky Lab\Kaspersky Anti-Virus 2009\mzvkbd.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\psapi.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\Program Files\Kaspersky Lab\Kaspersky Anti-Virus 2009\mzvkbd3.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\dinput.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\dinput.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\ddraw.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\dciman32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\dinput.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\msctf.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\Program Files\Logitech\SetPoint\GameHook.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\Program Files\Logitech\SetPoint\lgscroll.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.3053_x-ww_b80fa8ca\msvcr80.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\ntmarta.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\samlib.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\hid.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\wintrust.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\crypt32.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\msasn1.dll'
'Simutrans-Experimental-SDL.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\ddraw.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\dciman32.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\dinput.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\setupapi.dll'
'Simutrans-Experimental-SDL.exe': Unloaded 'C:\WINDOWS\system32\hid.dll'
The program '[5448] Simutrans-Experimental-SDL.exe: Native' has exited with code -1 (0xffffffff).

Any ideas what this problem might be?

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Compiling the SDL version in Windows
« Reply #14 on: May 10, 2009, 03:20:24 PM »
Sorry, not at all.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10669
  • Languages: De,EN,JP
Re: Compiling the SDL version in Windows
« Reply #15 on: May 10, 2009, 08:04:28 PM »
Wrong SDL version?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Compiling the SDL version in Windows
« Reply #16 on: May 10, 2009, 08:10:00 PM »
Which version should I have? I downloaded the latest...