[Beginner's question] Why the exe file cannot be opened in all computers?
By sn_2818184
@sn_2818184 (328)
Hong Kong
September 12, 2009 1:54pm CST
I've just started learning C++ programing in my university. To have a easy reference to my textbook, I use Microsoft Visual Studio 2005.
Of course, to start learning a programming language, the first program is usually the HelloWorld program. I'm no exception. I've learnt Pascal and thus, this is easy to me and a exe file is generated successuflly in the first time. It ran successfully in my computer.
However, when I move the file to another computer, the file cannot be run successfully, with the error message telling me that some setting of my program is wrong, asking me to reinstall the program. (which is of course impossible...)
The file path: C:\...\HelloWorldProject\debug\HelloWorldProject.exe
The only way out is to use the source code to compile the program again in that computer. However, the exe file compiled there also cannot be run in other computer. In other words, due to unknown reason(s), the exe file is machine dependent!
As far as I know, C++ is not a machine dependent programming language. So, what's wrong with my file? How can I compile a file that is machine independent?
3 people like this
5 responses
@myzire72 (1154)
• Singapore
12 Jan 10
I think you are lacking the .Net framework which is mandatory for your program to run. It's just like Java, if without the dependent classes, simply won't run. In fact, keep this in mind in future if you distribute or sell your software applications. Let your users know they have to install the .Net framework before they can run your software. If possible, include the link to download or let your software determine whether .Net framework is installed, and if not, download and install automatically from Microsoft.
@shanmukhsista (84)
• India
26 Oct 09
If you are using visual studio environment to develop a windows application then to run the program you must have dot net framework required that you selected when creating a new project.
Try running with .net installed or on windows vista or later. Windows vista contains .net framework inbuilt so no need for installing.
@kaka135 (14931)
• Malaysia
12 Oct 09
Well, I'm using Microsoft Visual Studio 2005 to build web applications, and some Windows applications too. I always created a setup file for me to install the Windows application in another computer, instead of just copy the executable file over, as the application needs to run with some other dependencies.
Have you checked the correct path for the HelloWorldProject.exe? As you mentioned the file path is C:\...\HelloWorldProject\debug\HelloWorldProject.exe, it seems to be the path in your computer where you developed the project, but the path may not exist in the other computer.
The executable file may need to run with some dependency files, I suppose .NET Framework is one of the dependencies. Though Microsoft said that the applications are machine-independent, it has to install .NET Framework at least, if I am not mistaken.
Try to create a setup file and install it in the other computer, it'll help you to install the necessary dependency files too.