简体   繁体   English

使用向量退出值127的MinGW C ++

[英]MinGW C++ using vector exit value 127

I have a problem using vector in C++. 我在C ++中使用vector时遇到问题。 I'm working with MinGW on Windows + NetBeans. 我在Windows + NetBeans上使用MinGW。

Following code: 以下代码:

#include <vector>
using namespace std;
int main(int argc, char** argv){
  vector<int> vec;
  return 0;
}

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). 它编译时没有任何错误,但运行时总是失败,退出值为-1.073.741.511或退出值为127(表示ERROR_PROC_NOT_FOUND)。

Starting the exe directly shows up with an error message like: 直接启动exe会出现如下错误消息:

entrypoint '__gx_personality_v0' not fount in 'libstdc++-6.dll'.

I have already tried -lstdc++ and 我已经尝试过-lstdc++

#include <cstdlib>

So what's the problem and how do I solve it? 那么问题是什么,我该如何解决呢?

Netbeans output: Netbeans输出:

"/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)

EDIT: Of course main should return int - fixed that and added using namespace std; 编辑:当然主要应该返回int - 修复并添加使用命名空间std;

Okay I found a solution. 好的,我找到了解决方案。

The problem was an installation of MiKTeX that was added to the PATH variable. 问题是添加到PATH变量的MiKTeX的安装。 So Windows linked to a different version of libstdc++-6.dll . 所以Windows链接到不同版本的libstdc++-6.dll

Finally I found two solutions: 最后我发现了两个解决方案

  1. Compile with -static-libstdc++ to avoid wrong DLL being linked. 使用-static-libstdc++以避免链接错误的DLL。

  2. Copy libstdc++-6.dll from MinGW\\bin into the same folder as the compiled EXE. libstdc++-6.dllMinGW\\bin复制到与编译的EXE相同的文件夹中。 This will cause windows to link always the correct version of the DLL. 这将导致Windows始终链接DLL的正确版本。

Although the problem is very specific, I hope that it helps others too. 虽然问题非常具体,但我希望它也有助于其他人。 ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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