Windows program instant crash: no messages.

Andrew Wiley wiley.andrew.j at gmail.com
Tue Jun 12 02:02:34 PDT 2012


On Tue, Jun 12, 2012 at 1:50 AM, Andrew Wiley <wiley.andrew.j at gmail.com> wrote:
> On Tue, Jun 12, 2012 at 1:32 AM, Dmitry Olshansky <dmitry.olsh at gmail.com> wrote:
>> On 12.06.2012 11:17, Nekroze wrote:
>>>
>>> Hello. I am trying to make a wrapper to use the DarkGDK 3d game engine
>>> for windows with D and i am doing rather well so far. I have just gotten
>>> it to successfully compile however the resulting exe instantly crashes
>>> and outputs nothing at all even though the very first command in WinMain
>>> is writeln which doesnt show up.
>>
>>
>> It may be the case that you need to call rt_init(); at first line of
>> WinMain. Every time I see WinMain problems it boils down to D runtime not
>> setup properly.
>
> I agree. Take a look at http://dlang.org/windows.html
> Working from that, I was able to get your app to begin to start up.
> The other trick is that when you structure your main this way,
> stdout/stderr/stdin don't seem to be set up for you (at least, not
> with MinGW GDC). I added this:
> stdout = File("test.txt", "w");
>
> and now test.txt contains this:
> %sCreating Swindow
> %sInitializing DarkGDK
>
> It's still crashing, but it's getting significantly farther. I haven't
> dug enough to figure out what's going on now.

Actually, it's not crashing, it's failing to initialize DarkGDK and
bailing nicely. Looks like it's probably because the DarkGDK DLL is 32
bit and I'm building a 64 bit executable.

If I switch to a 32 bit executable and add a stdout.flush() after
every writeln, I get this:
%sCreating Swindow
%sInitializing DarkGDK
%sStarting the window
%sHanind the window to DarkGDK


Unfortunately, I can't debug the crash for some reason. I'll have to
ping the MinGW GDC folks about it.

The code looks like this: http://pastebin.com/i5A3PFTt
My GDC build.bat looks like this: http://pastebin.com/PW30V3q4


More information about the Digitalmars-d-learn mailing list