0

As I've decided to dive enthusiastically into the open-source world, I downloaded the Eclipse IDE for C/C++ Developers (Kepler Service Release 1) and installed minGW.

I created a new project using minGW as the toolchain, and I can create the hello world program using <iostream>, but if I try to create a tuple, smart pointer, or any other c++0x thingy I get a "symbol not found" error:

#include <tuple>
int main(int in)
{
    std::tuple<int> lameTuple; // symbol "tuple" could not be resolved
    return 0;
}

I tried adding -std=c++0x to the Other flags in the GCC C++ Compiler tool settings but this didn't seem to help. Any ideas?

quant
  • 21,507
  • 32
  • 115
  • 211
  • Which version of GCC do you use? – Some programmer dude Oct 18 '13 at 13:04
  • [This question](http://stackoverflow.com/questions/17457069/enabling-c11-in-eclipse-juno-kepler-cdt) might help. – juanchopanza Oct 18 '13 at 13:04
  • @JoachimPileborg I have no idea. How do I find out? I'm using Eclipse for C/C++ developers (Kepler Service Release 1) – quant Oct 18 '13 at 13:07
  • Open a MinGW console, and enter the command `gcc --version`. – Some programmer dude Oct 18 '13 at 13:08
  • @JoachimPileborg I have no idea what a minGW console is. How do I open it? – quant Oct 18 '13 at 13:32
  • @juanchopanza I tried that top answer but it had no effect... – quant Oct 18 '13 at 13:32
  • Ok back to visual studio I think... – quant Oct 18 '13 at 13:36
  • If the paths are setup correctly, the normal console should work. Otherwise (if I remember correctly) there's a script in the MinGW root `bin` directory that you can run to setup the paths. When done, just run the command. – Some programmer dude Oct 18 '13 at 13:40
  • Have you tried using `-std=c++11`instead of `-std=c++0x` in the process that juanchopanza linked to above (http://stackoverflow.com/questions/17457069/enabling-c11-in-eclipse-juno-kepler-cdt). I gave it a try and it worked both for compiling as well as resolving the header/includes (using Eclipse Kepler sr1 with MinGW 4.7.2). Maybe c++11 isn't an option for you though. – jpw Oct 18 '13 at 13:50
  • As far as "mingw console", what should have been said is to open a command prompt in windows "cmd.exe", type "bash.exe" and hit enter. If you have msys installed with Mingw, this will open a bash console. From here, you can enter in "gcc --version" which will print out the GCC version bundled with MINGW –  Mar 25 '14 at 13:37

1 Answers1

2

I've run into this problem as well. Using Eclipse + Mingw GCC on windows is an incredibly.... egregious setup because of random issues like this. For example, I have one C++11 project in my workspace that requires no workarounds except for the std=c++11 or gnu flag, while others completely die regardless of this.

Unfortunately, the only answer is what I'd consider a hack. If you take a look in the Tuple header, you'll see:

#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else

So here the answer (solution) becomes evident. Somewhere, either a compiler flag or as a define in a .cpp file, you're going to want to define __cplusplus as greater than 201103L. How I did this was to go into

Project Properties->C/C++ General->Paths And Symbols

Then, under the "Symbols" tab, I added a new symbol. For the symbol name I used __cplusplus and for the value I used 201303L. This will force the indexer to re-run, at which time Eclipse will use the C++11 includes correctly.

On a side note, I think it's long over due for someone to create an Eclipse CDT + Mingw GCC installer which sets everything up properly. This issue is just scratching the surface of the incredible amount of issues you run into with this IDE and Toolchain, from bugged out versions of Mingw to poor indexing and parsing in the IDE. On that note always make sure that you're not using a buggy distribution of Mingw. This can also cause these issues.

Edit #1
Note also that you should include --std=X flag as a compiler flag under "miscellaneous", even when using this symbol. This symbol is just for the IDE to parse the headers with correct C++11 support.