MinGW C ++使用向量退出值127 [英] MinGW C++ using vector exit value 127
问题描述
我在C ++中使用向量时遇到问题.我正在Windows + NetBeans上使用MinGW.
I have a problem using vector in C++. I'm working with MinGW on Windows + NetBeans.
以下代码:
#include <vector>
using namespace std;
int main(int argc, char** argv){
vector<int> vec;
return 0;
}
它编译时没有任何错误,但是运行时总是失败,退出值为-1.073.741.511或退出值为127(这意味着ERROR_PROC_NOT_FOUND).
It compiles without any errors, but when run it always fails with exit value -1.073.741.511 or exit value 127 (that means ERROR_PROC_NOT_FOUND).
直接启动exe会显示错误消息,例如:
Starting the exe directly shows up with an error message like:
entrypoint '__gx_personality_v0' not fount in 'libstdc++-6.dll'.
我已经尝试过-lstdc++
和
#include <cstdlib>
那是什么问题,我该如何解决?
So what's the problem and how do I solve it?
Netbeans输出:
Netbeans output:
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Josch/CppApplication_1'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW1-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/c/Users/Josch/CppApplication_1'
mkdir -p build/Debug/MinGW1-Windows
rm -f build/Debug/MinGW1-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW1-Windows/main.o.d -o build/Debug/MinGW1-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW1-Windows
g++ -o dist/Debug/MinGW1-Windows/cppapplication_1 build/Debug/MinGW1-Windows/main.o
make.exe[2]: Leaving directory `/c/Users/Josch/CppApplication_1'
make.exe[1]: Leaving directory `/c/Users/Josch/CppApplication_1'
BUILD SUCCESSFUL (total time: 4s)
当然main应该返回int-修复该问题并使用命名空间std添加;
Of course main should return int - fixed that and added using namespace std;
推荐答案
好的,我找到了一个解决方案.
Okay I found a solution.
问题是MiKTeX
的安装已添加到PATH
变量中.因此Windows链接到libstdc++-6.dll
的其他版本.
The problem was an installation of MiKTeX
that was added to the PATH
variable. So Windows linked to a different version of libstdc++-6.dll
.
最后,我找到了两种解决方案:
Finally I found two solutions:
-
使用
-static-libstdc++
进行编译,以避免链接错误的DLL.
Compile with
-static-libstdc++
to avoid wrong DLL being linked.
将libstdc++-6.dll
从MinGW\bin
复制到与已编译EXE相同的文件夹中.这将导致Windows始终链接正确版本的DLL.
Copy libstdc++-6.dll
from MinGW\bin
into the same folder as the compiled EXE. This will cause windows to link always the correct version of the DLL.
尽管问题很具体,但我希望它也能对其他人有所帮助. ;)
Although the problem is very specific, I hope that it helps others too. ;)
这篇关于MinGW C ++使用向量退出值127的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!