MinGW C ++ using 127 vector output value

I have a problem using a vector in C ++. I work with MinGW on Windows + NetBeans.

The following code:

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

It compiles without any errors, but at startup it always fails with an output value of -1.073.741.511 or a value of 127 (this means ERROR_PROC_NOT_FOUND).

Running exe directly appears with an error message, for example:

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

I already tried -lstdc++ and

 #include <cstdlib> 

So what is the problem and how to solve it?

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.od g++ -c -g -MMD -MP -MF build/Debug/MinGW1-Windows/main.od -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 and add using the std namespace;

+4
source share
1 answer

Ok, I found a solution.

The problem was setting MiKTeX , which was added to the PATH variable. Therefore, Windows is associated with another version of libstdc++-6.dll .

Finally, I found two solutions:

  • Compile with -static-libstdc++ to avoid DLL binding.

  • Copy libstdc++-6.dll from MinGW\bin to the same folder as the compiled EXE. This will force windows to always refer to the correct version of the DLL.

Although the problem is very specific, I hope it helps others too .;)

+5
source

Source: https://habr.com/ru/post/1493516/


All Articles