• 15
• 15
• 11
• 9
• 10

# EXE OK within Visual C++ but crashes outside

This topic is 4303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites

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.

##### Share on other sites
Does:

int main(){return 0;}

work?

##### Share on other sites
Is that *all* your program does? There's no global classes or anything? What do youy mean it crashes? What error do you get?

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
Executable file "knows" to look for dlls in same path where the executable itself lies, "c\windows\", "c:\windows\system\" and "c:\windows\system32\".