Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In Ubuntu 12.04 LTS I installed the Eclipse CDT plugin and opened the new hello world project to just test everything out. When I was creating the project, I chose the only toolchain: "Linux GCC"

When the project is created, however, it says that

#include<iostream>
#include<cstdlb>

are unresolved. Thus, lines with cout and endl can't be used and it cannot find std.

using namespace std; is also causing problems.

How can I get my #include directives for standard library headers recognized, to support code using the std namespace?

share|improve this question
    
Do these errors persist even after you do Project > Build All? –  Eliah Kagan Jun 14 '12 at 16:00
2  
Mayne this is a stupid question but did you create a new project specifically as a C++ project rather than a C project? –  bazz Jul 26 '12 at 21:42
add comment

1 Answer

If you had the same issue I did, I suspect that your project builds but code-completion / code highlighting fails? I've just found some notes that may be useful. Here's what I did:

  • Project->Properties

  • C/C++ General

  • Paths and Symbols

  • select the appropriate language

  • Click "Add" and add the compiler-version specific directories

For language 'GNU C++' I added:

  /usr/include
  /usr/include/c++/4.6
  /usr/include/c++/4.6/bits
  /usr/include/i386-linux-gnu
  /usr/include/i386-linux-gnu/bits
  /usr/include/c++/4.6/debug
  /usr/include/c++/4.6/i686-linux-gnu
  /usr/include/c++/4.6/i686-linux-gnu/bits

For "GNU C" I added:

  /usr/include
  /usr/include/i386-linux-gnu
  /usr/include/i386-linux-gnu/bits

TBH, I don't think all the directories above are actually required (you could probably remove the 'bits' directories) but the list above worked for me at the time.

I am now using Eclipse Indigo (version 3.7.2) from eclipse.org and it automatically finds and adds the correct include directories. The list is different for me:

/usr/include/c++/4.6
/usr/include/c++/4.6/i686-linux-gnu
/usr/include/c++/4.6/backward
/usr/lib/gcc/i686-linux-gnu/4.6/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6/include-fixed
/usr/include/i386-linux-gnu
/usr/include

Clearly, only add the include directories that actually exist on your system ;-)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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