How to make Eclipse CDT's Linux GCC toolchain resolve C++ standard library headers?
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 ;-)
Comments
-
M.D. over 1 year
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
andendl
can't be used and it cannot findstd
.using namespace std;
is also causing problems.How can I get my
#include
directives for standard library headers recognized, to support code using thestd
namespace?-
Eliah Kagan almost 12 yearsDo these errors persist even after you do
Project
>Build All
? -
bazz almost 12 yearsMayne this is a stupid question but did you create a new project specifically as a C++ project rather than a C project?
-
-
einpoklum over 8 yearsWell, this doesn't work for me - although I'm actually on Debian Stretch 64-bit. But I did adapt your suggestions to my platform.