exe crashes when run manually, runs fine within codeblocks

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
yablebab
Posts: 5
Joined: Wed Sep 20, 2006 9:20 pm
Location: Berkeley, CA

exe crashes when run manually, runs fine within codeblocks

Post by yablebab »

First, the background:
WindowsXP
Code::Blocks IDE Sep 6, 2006 build
wxWidgets 2.7
Irrlicht Graphics Engine v 1.1

I'm building a win32 app with irrlicht embedded in a wx control. When I compile for debug, and press F9 (run) in codeblocks, it runs perfectly. But when I try and run the exe externally (just double-clicking on the .exe file) it crashes. Also, if I compile for release it won't run either way. This is a huge problem! Anyone ever heard of this happening before?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You've got an error somewhere then, like an uninitialised variable or something. I had this before with Dev-C++ and i think it was because i hadn't initialised a wchar_t*, it dealt with it when running in the IDE as the IDE basically did it for me, but the .exe doesn't

So you'll have to track down which part of your code is crashing. I've never really used debuggers but i'm sure they could help you. The way i always do it is by using print statements in my code so i can read off from the console how far through the code my program's got and then i can narrow it down to which line of code is crashing and then investigate what's causing the crash.
Image Image Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes, could be an uninitialized variable or maybe a file access problem. Try running the code under the debugger, then when it crashes, have a look at where it crashes. You can also try compiling your code with warnings on high. That will expose some uninitialized variable errors.

Travis
sRc
Posts: 431
Joined: Thu Jul 28, 2005 1:44 am
Location: Salt Lake City, Utah
Contact:

Post by sRc »

is the dll in the same place as the exe? its gonnna crash ohterwise if you try running it externally :wink: (wehereas when you run it from the IDE it loads it from the bin folder thats defined)
The Bard sRc

Blog | Twitter
yablebab
Posts: 5
Joined: Wed Sep 20, 2006 9:20 pm
Location: Berkeley, CA

Post by yablebab »

Yes, the dll is in the same place as the .exe.

But, I found a couple of pointers that were uniitialized, which I thought could be causing the crash. The problem is, I have a whole bunch of pointers declared from within a class, like so:

Code: Select all


class MyWindow: public wxWindow
{
public:
    ... 
    ... 
private:
    ...
    wxNotebook* ToolNB;

    wxWindow* EventAnalysisWin;
    wxWindow* DetectorWin;
    wxWindow* MultimediaWin;
    ...
};
Of course, trying to initialize any of these NULL causes an error: only static const integral data members can be initialized within a class.

Are there any ways around this?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

initialise them in the constructor :)
Image Image Image
Post Reply