1

In Eclipse I am using mingw-w64 V5.3.0 as the compiler and I have enabled C++11 (which was the solution in the following related post here and here). My compilation command looks as follows (from eclipse console window):

g++ -std=c++11 -O0 -g3 -Wall -c -fmessage-length=0 -o "src\Launch.o" "..\src\Launch.cpp"

The simple code I am attempting to run is as follows:

#include <stdio.h>
#include <iostream>
#include <string>

int main()
{
    std::string test = std::to_string(0);
    std::cout <<"HI" << std::endl;
    return 0;
}

The program compiles but for an error stated in the question. Running it without the to_string line works fine. There have been suggestions back in 2012 that MingW has a problem with to_string(), but was resolved in later versions has shown here.

Screen shot below:

enter image description here

And the console output is as follows:

enter image description here

The following is the error I receive when running the code from the .exe directly:

enter image description here

As mentioned in the comments, the issue is a linking issue, however it is linking correctly to iostream which is in the same directory as string.

Community
  • 1
  • 1
Single Entity
  • 2,925
  • 3
  • 37
  • 66

1 Answers1

0

Eclipse was looking in System32 for the library and driver files, despite PATH and Eclipse pointing to the MingW64 compiler on the computer. Eclipse is also showing it is linked to the MingW64 libraries correctly as the path to the headers when right-clicking and opening deceleration is shown to be correct. Why then it looks in System32 for the library at run-time I don't understand.

The problem was 'solved' by copying the entire MingW64 compiler driver folder into the System32 folder on Windows.

Single Entity
  • 2,925
  • 3
  • 37
  • 66
  • Yikes! I'd check if eclipse is configured to override some environment variables in the project properties. An alternative would be to link libstdc++ statically, if you really can't fix your environment. – melak47 Apr 08 '16 at 14:07