Eclipse 3.7.1 CDT 1.4.1 GCC 4.6.2
This is an example of a piece of C++11 code:
auto text = std::unique_ptr<char[]>(new char[len]);
The Eclipse editor complains about:
Function 'unique_ptr' could not be resolved
The Makefile compilation works fine. How to make Eclipse stop complaining about these sort of errors?
To get support for C++14 in Eclipse Luna, you could do these steps:
C++ General -> Preprocessor Include -> Providers -> CDT Cross GCC Built-in Compiler Settings
, add "-std=c++14"C++ Build -> Settings -> Cross G++ Compiler -> Miscellaneous
, add "-std=c++14"Reindex your project and eventually restart Eclipse. It should work as expected.
I solved it this way on a Mac. I used Homebrew to install the latest version of gcc/g++. They land in /usr/local/bin with includes in /usr/local/include.
I CD'd into /usr/local/bin and made a symlink from g++@7whatever to just g++ cause that @ bit is annoying.
Then I went to MyProject -> Properties -> C/C++ Build -> Settings -> GCC C++ Compiler and changed the command from "g++" to "/usr/local/bin/g++". If you decide not to make the symbolic link, you can be more specific.
Do the same thing for the linker.
Apply and Apply and Close. Let it rebuild the index. For a while, it showed a daunting number of errors, but I think that was while building indexes. While I was figuring out the errors, they all disappeared without further action.
I think without verifying that you could also go into Eclipse -> Properties -> C/C++ -> Core Build Toolchains and edit those with different paths, but I'm not sure what that will do.
For Eclipse CDT Kepler what worked for me to get rid of
std::thread
unresolved symbol is:Go to Preferences->C/C++->Build->Settings
Select the Discovery tab
Select CDT GCC Built-in Compiler Settings [Shared]
Add the -std=c++11 to the "Command to get the compiler specs:" field such as:
Adding
-std=c++11
to projectProperties/C/C++ Build->Settings->Tool Settings->GCC C++ Compiler->Miscellaneous->Other
Flags wasn't enough for Kepler, however it was enough for older versions such as Helios.I had several issues too (Ubuntu 13.04 64-bit, g++-4.8, eclipse Juno 3.8.1, CDT 6.0.0). A lot of things are mentioned above, sorry to repeat those, but additionally I had problems utilizing
as part of c++11 (adding -pthread for the linker solves that issue). Anyway, finally these settings worked fine:
Project -> Properties -> C/C++ Build -> Settings -> Miscellaneous. Add the
flag for the GCC and G++ compilers. Click Apply.
For the linker, same window, Miscellaneous, Linker flags, added the
flag. Shared library settings, Shared object name, add the
flag too. Click Apply.
C/C++ General -> Paths and symbols -> Symbols TAB, GNU C++ selected, Add the
(no value)
flag. Click Apply.
C/C++ General -> Preprocessor Include paths.. -> Providers tab : check
CDT GCC built-in Compiler Settings
and for "Command to get compiler specs", add the
flag. Uncheck Share. Click Apply.
CDT Managages Build Setting Entries, check this too. Uncheck the two others. Click Apply.
Going back to the Entries tab, GNU C++ CDT Managages Build Setting Entries, you should now see your added
entry.
That's it. When coding, typing
can now auto-complete the thread class for instance, builds should work fine and there should be no
at runtime.
For the latest (Juno) eclipse cdt the following worked for me, no need to declare
__GXX_EXPERIMENTAL_CXX0X__
on myself. This works for the the CDT indexer and as parameter for the compiler:"your project name" -> right click -> properties:
C/C++ General -> Preprocessor Include Paths, Macros etc. -> switch to the tab named "Providers":
for "Configuration" select "Release" (and afterwards "debug")
switch off all providers and just select "CDT GCC Built-in Compiler Settings"
uncheck "Share setting entries between projects (global provider)"
in the "Command to get compiler specs:" add "-std=c++11" without the quotes (may work with quotes too)
hit apply and close the options
rebuild the index
Now all the c++11 related stuff should be resolved correctly by the indexer.
win7 x64, latest official eclipse with cdt mingw-w64 gcc 4.7.2 from the mingwbuilds project on sourceforge
I had the same problem on my Eclipse Juno. These steps solved the problem :
Project -> Properties -> C/C++ General -> Path and Symbols -> Tab [Symbols]
.