User forums > Using Code::Blocks
.exe crashes but works fine from within codeblocks
(1/1)
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 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?
thomas:
If you had said "press F8" then the problem would be obvious: an uninitialised pointer in your code.
But having that problem with "F9" is kind of odd. It doesn't do much but execute the program after building it. So except for the program being in a different memory region, all is the same (dread to think of faulty RAM). You don't play any complicated relocation tricks, I trust?
It is surprising even more so as compiling debug/release shouldn't make any difference at all (the only difference is symbols being added, it is still the very same code).
Sometimes, an exotic compiler option can have nasty results, too. Can you post the build commandline (at least one complete compiler and one complete linker line)?
Though I doubt it will help, maybe one can see something wrong in there... :?
kidmosey:
Is your working directory the same as the output directory? If you are loading from a non-existant resource file and not checking if it exists, you could get all sorts of nulls.
yablebab:
So 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: ---class MyWindow: public wxWindow
{
public:
...
...
private:
...
wxNotebook* ToolNB;
wxWindow* EventAnalysisWin;
wxWindow* DetectorWin;
wxWindow* MultimediaWin;
...
};
--- End code ---
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?
kidmosey:
you do it in the constructor.
--- Code: --- MyWindow():
wxWindow(),
ToolNB(NULL),
EventAnalysisWin(NULL),
DetectorWin(NULL),
MultimediaWin(NULL)
{
}
--- End code ---
or
--- Code: --- MyWindow(): wxWindow()
{
ToolNB = NULL;
EventAnalysisWin = NULL;
DetectorWin = NULL;
MultimediaWin = NULL;
}
--- End code ---
even better would be to give them default values instead of NULL. Are you using any external resource files?
Navigation
[0] Message Index
Go to full version