8

Using Eclipse Mars, I am getting the Symbol 'unique_ptr' could not be resolved error. I tried adding -std=c++11 to CDT GCC Built-in Compiler Settings, but this didn't help. The error goes away when I reopen Eclipse, but if I make a modification to the code, the error comes back.

One simple code sample:

std::unique_ptr<String> p1;
2
  • 2
    Did you #include <memory> ?
    – Bathsheba
    Nov 12, 2015 at 8:20
  • 1
    I did, yes, but it didn't help. Nov 14, 2015 at 3:20

1 Answer 1

15
  1. In Eclipse Mars open Window > Preferences > C/C++ > Build > Settings > Discovery > CDT GCC Build-in Compiler Settings
  2. Append -std=c++11 to the Command to get compiler specs
  3. Press OK
  4. Rebuild the index: Project > C/C++ Index > Rebuild
3
  • 2
    For me it was necessary to 5. Restart Eclipse For whatever reason?!
    – IanH
    Aug 21, 2016 at 8:53
  • And in my case I had to rebuild the index ( Right-Click on Project > Index > Rebuild ) in the end. Jan 3, 2017 at 11:18
  • Also, std::make_unique is only defined in C++14 and later compilers (stackoverflow.com/questions/24609271/…).
    – jigglypuff
    Feb 26, 2018 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.