A few days ago I started programming with C after programming with C++, however, my Windows Vista 64bit machine was unable to create a C project. I recompiled the code with the MinGW Dev-C++ compiler without issue.
However, when I ran the code I received the following error:
Unsupported 16-Bit Application
The program or feature
"\??\C:\Dev-Cpp\gcc.exe"
cannot start or run due to incompatibity with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available.
Is this a pr开发者_Go百科oblem with compiling C code using a C++ compiler?
I got the same error message when accidentally adding the -c
switch which tells the compiler to not link the executable. Removing the switch made it work again.
> gcc --help
...
-c Compile and assemble, but do not link
The error you're seeing is from using an ancient (as in 16-bit Windows 3.1 era) software that Windows 64-bit does not provide backwards-compatibility for. This has nothing to do with C or C++, just a really old compiler.
You can either install windows 7 with XP-mode, which provides a virtual 32-bit XP machine running nearly seamlessly under Windows 7, or some other 32-bit virtualization solution or download a newer version of gcc.exe or some other compiler that's less than 20 years old:
See cygwin, MingGW, or Visual Studio Express.
It is some kind of problem with Mingw. The problem is not because you are using an old compiler. It happened to me with the last version of Mingw compilers. I found a workaround that may help some people. This problem manifests when building my project with a Makefile. If I build it manually by the command line it works fine, the resulting .exe executes with no problems.
By compiling manually I mean for example for c++:
c:\mydir> g++ source1.cpp source2.cpp -o myprog.exe
My application was very small, just a few sources I needed to test some changes. If you have a more complex application with a Makefile this workaround probably won't help you.
I had a similar problem and it was msiemens' answer that give me the hint to solve it. It's not related to the MinGW version. It was just that my .exe file was not actually an executable.
I was trying to compile and build with the command:
> g++ -c cpptest.cpp -o cpptest.exe
But with -c, g++ just compiles without linking. The resulting cpptest.exe is just the cpptest.o file (binary object file, but not executable) with a different name.
To compile and link I then used (as indicated by Alejandro):
> g++ cpptest.cpp -o cpptest.exe
Or in two steps:
> g++ -c cpptest.cpp -o cpptest.o
> g++ cpptest.o -o cpptest.exe
These create the actual executable.
I had the same error while using Notepad++, I found the mistake I made. I was trying to create an executable file from a header file.
The file needs to be saved as a file.cpp or file.c instead of file.hpp or file.h
I was also switching languages, however from C to C++
精彩评论