EXE OK within Visual C++ but crashes outside

Started by
15 comments, last by Kiristu 17 years, 10 months ago
Hi, I'm working with Visual C++ 2005 Express to compile and run my application. No problem when I launch from the run button in Visual, but when I try to launch it directly by double-clicking on the .exe file, it crashed with a basic Windows error saying the application encountered a problem and must close. It could be caused by some compiler settings by I don't know which ... Any idea ? Thank you, K.
Advertisement
Maybe some files that you load inside your program are missing. Your program can't find them and you haven't done error checking(program continues executing without them).
Probably are your data files somewhere in sources dir, but are missing in debug dir.
Use full paths when you load your data.
Thanks for your answer, but that is not the problem:

I modified my code to have:

int APIENTRY WinMain(HINSTANCE hInstance,                     HINSTANCE hPrevInstance,                     LPSTR     lpCmdLine,                     int       nCmdShow){    return 0;}


And the error is still there !

SO the program does not have to do anything else than to quit ...

K.
Does:

int main(){return 0;}


work?
Is that *all* your program does? There's no global classes or anything? What do youy mean it crashes? What error do you get?
int main(){return 0;}


has the same result ...

It crashes = pop-up window with a message saying my exe encountered a problem and must close, with buttons to send the error report or not (also a link with click here to access the report details, but nothing I can understand in it).

Of course, my application does have a lot of global classes, but having said that, why can it work differently in Visual than from exe file ?

Thanks,
K.
When he said global classes he meant global instances of those classes. That is, do you have global variables that are going to be constructed and destructed (in essence doing more than just a return 0)? If you do, then that's where the problem lies: it's probably a constructor trying to load a file or DLL that isn't in the right directory.
OK, that could be the problem.

Since I can know the dll I include in the project via the compiler/project settings, how can I specify the "path" ?

It's a DirectX application (with DX specific global classes), so I need a number of external files, I thought the executable file "knows" where it has to look for them ...

Thanks,
K.
Executable file "knows" to look for dlls in same path where the executable itself lies, "c\windows\", "c:\windows\system\" and "c:\windows\system32\".
I've never seen int main() work in a Win32 project. If you had WinMain you cannot replace it with main() and have it still compile in VS. It's never worked when I've done it. Could something else be up?

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement