Reputation: 23052
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?
Upvotes: 0
Views: 1273
Reputation:
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.
Upvotes: 2