NetBeans’ “Unable to resolve identifier std” error

Tried to use some C++ STL includes to no avail. But it was odd, NetBeans was underlining my include’s with a red groovy line, and still managed to compile successfully (obvious, because gcc is the compiler, not NB).

So this:

#include <string>


std::string m_strTest;

were both underlined, and a “Unable to resolve identifier std” error appeared to the left, with the classic question mark with red background signal.

I was using NB 6.7; tried with NB 6.8 Beta and the problem persisted.

But turns out it was a very simple fix. Thanks to this post which suggested to use CTRL+ALT when hovering over include’s, I found out that several include paths such as /usr/lib/include/c++/4.3 weren’t found (they were marked in red, not surprisingly). So if netbeans couldn’t find those directories, it wasn’t able to determine whether std:: was a proper identifier or not.

Simple test:

sole@courgette:~$ ls -la /usr/include/c++
total 20
drwxr-xr-x  3 root root  4096 2009-11-01 11:47 .
drwxr-xr-x 65 root root 12288 2009-11-24 17:18 ..
drwxr-xr-x 10 root root  4096 2009-11-01 11:22 4.4
lrwxrwxrwx  1 root root     3 2009-11-01 11:22 4.4.1 -> 4.4

ahh so it’s not 4.3 but 4.4!

So I went to Tools -> Options -> C/C++ -> Code Assistance and replaced the occurrences of 4.3 with 4.4 where appropriate. All worked perfectly from that point onwards.

It’s strange; I don’t remember having updated GCC recently (apart from the update to Karmic Koala). In any case I hadn’t been using NetBeans with C++ and std recently either, so maybe the problem was there waiting for me to stumble upon it 🙂

6 Replies to “NetBeans’ “Unable to resolve identifier std” error”

  1. That problem was really bugging me, but I was too busy and too lazy to find the solution. Thanks for the good contribution.


  2. Massive thanks for this, it really helped. For me, 4.5 was the version, and it existed just fine. But some other paths were referencing 4.5.2 – which also exists just fine. I just updated them all to reference 4.5.2 and things seemed to resolve.

    Thanks again 🙂

Comments are closed.