无法运行用MinGW Dev-C编译的C程序++在 64 位 Vista 上
几天前,我在使用 C++ 编程后开始使用 C 编程,但是,我的 Windows Vista 64 位机器无法创建 C 项目。我用 MinGW Dev-C++ 编译器重新编译了代码,没有问题。
但是,当我运行代码时,我收到以下错误:
不支持的 16 位应用程序
由于与 64 位版本的 Windows 不兼容,程序或功能
“\??\C:\Dev-Cpp\gcc.exe”
无法启动或运行。请联系软件供应商询问是否有 64 位 Windows 兼容版本。
这是使用C++编译器编译C代码的问题吗?
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 problem with compiling C code using a C++ compiler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
当我意外添加
-c
开关时,我收到了相同的错误消息,该开关告诉编译器不要链接可执行文件。拆下开关后,它又可以工作了。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.您看到的错误是由于使用了一种古老的(如 16 位 Windows 3.1 时代)软件,而 Windows 64 位不提供向后兼容性。这与 C 或 C++ 无关,只是一个非常古老的编译器。
您可以使用 XP 模式安装 Windows 7,它提供了在 Windows 7 下几乎无缝运行的虚拟 32 位 XP 计算机,也可以安装其他 32 位虚拟化解决方案,或者下载较新版本的 gcc.exe 或其他版本较低的编译器。 20 岁以下:
请参阅 cygwin、MingGW,或 Visual Studio Express。
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.
这是 Mingw 的某种问题。问题不是因为您使用的是旧编译器。我在使用最新版本的 Mingw 编译器时就遇到过这种情况。
我找到了一个可能对某些人有帮助的解决方法。当使用 Makefile 构建我的项目时会出现此问题。如果我通过命令行手动构建它,它可以正常工作,生成的 .exe 执行时不会出现任何问题。
通过手动编译,我的意思是对于 c++:
我的应用程序非常小,只需要几个源来测试一些更改。如果您有一个带有 Makefile 的更复杂的应用程序,则此解决方法可能对您没有帮助。
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++:
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.
我有一个类似的问题,正是msiemens的回答给了我解决它的提示。与MinGW版本无关。只是我的 .exe 文件实际上并不是可执行文件。
我试图使用以下命令进行编译和构建:
但是使用 -c 时,g++ 只是编译而不链接。生成的 cpptest.exe 只是名称不同的 cpptest.o 文件(二进制目标文件,但不可执行)。
为了编译和链接,我然后使用(如 Alejandro 所示):
或者分两步:
这些创建实际的可执行文件。
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:
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):
Or in two steps:
These create the actual executable.
我在使用Notepad++时遇到了同样的错误,我发现了我犯的错误。我试图从头文件创建可执行文件。
该文件需要保存为 file.cpp 或 file.c,而不是 file.hpp 或 file.h
我也在切换语言,但是从 C 到 C++
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++