digitalmars.D.learn - Windows program instant crash: no messages.
- Nekroze (23/23) Jun 12 2012 Hello. I am trying to make a wrapper to use the DarkGDK 3d game
- Dmitry Olshansky (6/11) Jun 12 2012 It may be the case that you need to call rt_init(); at first line of
- Andrew Wiley (12/22) Jun 12 2012 I agree. Take a look at http://dlang.org/windows.html
- Andrew Wiley (14/38) Jun 12 2012 Actually, it's not crashing, it's failing to initialize DarkGDK and
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. Here is a link of the projects files at the moment https://dl.dropbox.com/u/27223793/dlangtest.zip and contains only a subset of the DarkGDK engine. I cannot promise that link will be around forever though. The problem may be the way that i am building it, i am using MonoDevelop Mono-D on windows, so i made a .bat file to try and do the same thing and it compiles but still crashes instantly and outputs nothing. As this is the first working compilation of this little project i am sure that parts of it dont exactly work right however i because the first command given after WinMain is a writeln i am lead to believe that the problem may not be with my code. but rather the way it is interacting or building it. Any assistance would be greatly appreciated along with some understanding as i am new to D but quite enjoy it even with the learning curve of moving from python to D. Thank you for your time, Nekroze.
Jun 12 2012
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. -- Dmitry Olshansky
Jun 12 2012
On Tue, Jun 12, 2012 at 1:32 AM, Dmitry Olshansky <dmitry.olsh gmail.com> wrote:On 12.06.2012 11:17, Nekroze wrote: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.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.
Jun 12 2012
On Tue, Jun 12, 2012 at 1:50 AM, Andrew Wiley <wiley.andrew.j gmail.com> wrote:On Tue, Jun 12, 2012 at 1:32 AM, Dmitry Olshansky <dmitry.olsh gmail.com> wrote: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/PW30V3q4On 12.06.2012 11:17, Nekroze wrote: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.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.
Jun 12 2012
On Tuesday, 12 June 2012 at 09:03:43 UTC, Andrew Wiley wrote:On Tue, Jun 12, 2012 at 1:50 AM, Andrew Wiley <wiley.andrew.j gmail.com> wrote:Great, thanks for the help so far. I have altered some of the code for main.d and simplewindow.d to incorporate these tips. Mainly i have offloaded WinMain to simpleWindow.d and made it call GDKmain which is my new main(post WinMain) function in the main.d i had wanted to do this originally as i didn't like making the end-user have to have a WinMain with all these args that they don't need for this engine and the need to export windows. There may be issues with doing this later on but for the moment i like it this way except for the fact that showWindow in GDKmain needs the nCmdShow from WinMain so i have to pass that along to it still. I have also reordered the way things are called in main.d so that things make more sense, so it tries to initialize the dll (and fails) then starts creating the window, you don't want a window just sitting there blank and non responsive while the dll initializes so thats what i have done. Yes the dll is 32bit, i am just using plain dmd and haven't had any problems as i believe its just doing 32bit as i wanted it to. I did actually have the runtime initialization in the Swindow.start but i guess it has to be a part of WinMain to work. I just replaced the file at the previous download link in the OP so if you re-download from there you get the new version with the adjustments. also i added kernel32.lib to the build as MonoDevelop seems to do that so i thought i should too. Thanks for the help so far guys, cant wait to get this to work!On Tue, Jun 12, 2012 at 1:32 AM, Dmitry Olshansky <dmitry.olsh gmail.com> wrote: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/PW30V3q4On 12.06.2012 11:17, Nekroze wrote: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.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.
Jun 12 2012
OK, another update to the original download link. I have gotten initDarkGDK to pass and it gets all the way down to handing the screen over to DarkGDK using the wrapper function dbOpenScreen but fails after that. I guess then my problem is in the wrapper function or in the actual template that it builds but I'm not sure where as i am still very new to templating.
Jun 12 2012