Not able to execute the .exe file generated from GCC compiler

Viewed 1379

I am working on creating a system in C language and I have installed GCC compiler via MinGW Installer. After this, I created a basic Hello World program to check if the compiler is working properly. I compiled my code using the command gcc hello.c -o hello and then tried to run the executable file thus created by typing hello into the command prompt. But the system is not running my .exe file and giving an error - The system cannot execute the specified program.

I repeated the whole process on my second system, step by step, and I was able to see the output for the same program on the command prompt without any error.

I am not able to understand the exact reason behind this but I suspect it has something to do with the permission to execute a .exe file.

1 Answers

Open your .exe file with Dependancy Walker (https://www.dependencywalker.com/). It will tell you if there is something wrong with the file.

Also you should be able to see there if it's 32-bit or 64-bit. In case of 64-bit it won't run on your system if you're on a 32-bit Windows.

You could also try with MinGW-w64 built from http://winlibs.com/ (try the 32-bit version first) and follow the hello world instructions on that site.

Related