简体   繁体   中英

mingw32: all compiled executables hang

I've just installed the most recent version of mingw32 and trying to compile even a hello world c++ program fails.

Installation was in the default C:/MinGW directory. I chose the option to install with mingw-get gui, and I selected the Basic Setup tab on the left-hand column, marked the mingw32-base and mingw32-gcc-g++ options for installation. Then I applied changes and downloaded all the files. Lastly I added C:/MinGW/bin to the path of windows.

Now I create a file that looks like this:

test.cpp:

#include <iostream>

int main() {
    std::cout << "hello world!" << std::endl;
    return 0;
}

and then I compile with g++ test.cpp

Now, the problem is a bit harder to diagnose. When I execute the output a.exe file, the command line simply hangs, no output, no return. If I try and cancel execution with ctrl-c, nothing happens. When I forcefully exit out of the command line, and try to delete a.exe, windows tells me the executable is currently opened by system, and the only way to forcefully remove the file is with FileASSASSIN.

Some notes, I have visual studio 12 installed, but nothing pertaining to it in the path. I had a previous installation of cygwin64 but it has been removed entirely. I get the same behavior running it from powershell, normal command line, or Console2. Google suggested I try statically linking libstdc++ with -static-libstdc++ to no avail.

Also, when compiled with debugging symbols and then ran with gdb a.exe , and then you run start, it also hangs just the same.

I'm out of ideas on getting information for troubleshooting here. Does anyone have any insight?

On the suggestion of @MM, I discovered that avast antivirus was the silent cause of halting any executables made by mingw32. This was puzzling, because I was running executables made by visual studio on command line only a few hours ago.

The lesson: If you encounter unexpected behavior, always try your antivirus.

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