eclipse添加C/C++头文件跳转

转载:http://blog.csdn.net/wudiwo/article/details/7682320

 Eclipse 中新建C 或C ++到项目时,头文件报警,显示“Unresolved inclusion:<stdio.h>” 虽然不影响项目到编译和运行,确也无法查看头文件,让人感觉实在不爽。下面是在国外到网站上看到解决方案,自己整理了一下拿来分享一下。关于在Eclipse 下配置C /C ++ 开发环境这里不多说了。

 在终端下查看C 库文件到路径:

$ echo "int main() { return 0; }" > a1.c

$ gcc -v a1.c

 

#include "..." search starts here:
#include <...> search starts here:

/usr/lib/gcc/x86_64-linux-gnu/4.9/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include

搜索列表结束。

……

查看C++ 库文件到搜索路径:

$ echo "int main() { return 0; }" > a1.cpp

$ g++ -v a1.cpp

#include "..." search starts here:
#include <...> search starts here:

 

/usr/include/c++/4.9
/usr/include/x86_64-linux-gnu/c++/4.9
/usr/include/c++/4.9/backward
/usr/lib/gcc/x86_64-linux-gnu/4.9/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include


搜索列表结束。

上述路径因人而异。

 

在eclipse中菜单Window --> Preferences --> C/C++ --> Build --> Environment添加环境变量

C_INCLUDE_PATH =/usr/lib/gcc/x86_64-linux-gnu/4.9/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include

CPLUS_INCLUDE_PATH =/usr/include/c++/4.9:/usr/include/x86_64-linux-gnu/c++/4.9:/usr/include/c++/4.9/backward:/usr/lib/gcc/x86_64-linux-gnu/4.9/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include

记得选中下面的Append variables to native environment.

添加完后重启Eclipse 新建项目即可。

posted on 2015-04-16 14:08  skywalker0011  阅读(2938)  评论(0编辑  收藏  举报

导航