[英]Mingw runtime error
I'm a new user of MinGW, and I have already run into problems. 我是MinGW的新用户,我已经遇到了问题。 When attempting to compile a very simple Hello world c++ program, I get an error.
在尝试编译一个非常简单的Hello world c ++程序时,我收到一个错误。 I type the command:
我输入命令:
g++ hello.cpp -o hello.exe
and then I get the message dialog: 然后我得到消息对话框:
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: c:\mingw\bin\...\libexec\gcc\mingw32\4.8.1\cc1plus.exe
R6034:
An application has made an attempt to load the C Runtime library incorrectly.
Please contact the application's support team for more information.
followed immediately by this message dialog: 紧接着是这个消息对话框:
cc1plus.exe - Program error
The application failed to initialize properly
(0xc0000142). Press OK to close application.
And then the usual junk about Windows finding a solution online. 然后是关于Windows在线寻找解决方案的常见垃圾。
I used the automatic installer mingw-get-setup.exe
and simply followed the instructions. 我使用了自动安装程序
mingw-get-setup.exe
,只需按照说明操作即可。 I chose the installation folder to be C:\\mingw
, and in the MinGW Installation Manager, I chose to install mingw-developer-toolkit
, mingw32-base
, mingw32-gcc-g++
, mingw32-gcc-objc
and msys-base
. 我选择安装文件夹为
C:\\mingw
,在MinGW Installation Manager中,我选择安装mingw-developer-toolkit
, mingw32-base
, mingw32-gcc-g++
, mingw32-gcc-objc
和msys-base
。 As suggested in the installation guide, I added PATH
in the Environment Variables
. 正如安装指南中所建议的那样,我在
Environment Variables
添加了PATH
。
The code I was trying to compile was: 我试图编译的代码是:
#include <iostream>
using namespace std;
int main(int argc, char ** argv){
cout << "hello world" << endl;
return 0;
}
I also tried to compile a similar ANSI-C code with the command: 我还尝试使用以下命令编译类似的ANSI-C代码:
gcc hello.c -o hello.exe
and I got the same error. 我得到了同样的错误。
I tried the command in cmd.exe
as well as in MSYS and got the error in both cases. 我在
cmd.exe
以及MSYS中尝试了该命令,并在两种情况下都得到了错误。 My operating system is Windows Vista Home Premium, and I have Microsoft Visual C++ 2010 installed on it. 我的操作系统是Windows Vista Home Premium,我安装了Microsoft Visual C ++ 2010。 I mention this because I tried to do the same installation on a windows 7 computer without VC++ and here the compiler worked without problems.
我之所以提到这一点是因为我尝试在没有VC ++的Windows 7计算机上进行相同的安装,这里编译器没有问题。 Does this mean that you can't have MinGW and VC++ on the same computer?
这是否意味着你不能在同一台计算机上安装MinGW和VC ++?
The problem was, as suggested in the comments, that programs other than the Gnu Compiler had left values in the %PATH% variable. 正如评论中所建议的那样,问题是Gnu编译器以外的程序在%PATH%变量中留下了值。 What I did not initially notice, was the fact that there are two %PATH% variables, one for the user and one for the system, and both can interfere with the MinGW installation.
我最初没有注意到的事实是,有两个 %PATH%变量,一个用于用户,一个用于系统,两者都可能干扰MinGW安装。
The system %PATH% variable contains (at least on my PC) quite a lot of entries and removing all of them might not be a good idea. 系统%PATH%变量包含(至少在我的PC上)相当多的条目并删除所有条目可能不是一个好主意。 In my case, however, it was sufficient to remove entries from MatLab and Texnic Center.
但是,在我的情况下,从MatLab和Texnic Center删除条目就足够了。 Afterwards, g++ and gcc worked flawless.
之后,g ++和gcc完美无瑕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.