简体   繁体   中英

Mingw runtime error

I'm a new user of MinGW, and I have already run into problems. When attempting to compile a very simple Hello world c++ program, I get an error. 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.

I used the automatic installer mingw-get-setup.exe and simply followed the instructions. 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 . As suggested in the installation guide, I added PATH in the Environment Variables .

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:

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. My operating system is Windows Vista Home Premium, and I have Microsoft Visual C++ 2010 installed on it. 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. Does this mean that you can't have MinGW and VC++ on the same computer?

The problem was, as suggested in the comments, that programs other than the Gnu Compiler had left values in the %PATH% variable. 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.

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. In my case, however, it was sufficient to remove entries from MatLab and Texnic Center. Afterwards, g++ and gcc worked flawless.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM