看到这篇文章不错,mark一下,原文链接如下:
http://www.cnblogs.com/logicbaby/archive/2011/10/19/2217254.html
使用eclipse cdt开发C/C++项目的时候,从eclipse官网下的linux下的专门版本在Fedora上能自动Discovery机器上的gcc/g++头文 件、符号之类的,但是在我用的slackware下却不行,需要手动添加标准库头文件路径/usr/include、/usr/local /include……,但这样也比较麻烦,今天查了下可以通过设置C_INCLUDE_PATH/CPLUS_INCLUDE_PATH实现。
$ echo "int main() { return 0; }" > a1.c
$ gcc -v a1.c
……
#include "..." 搜索从这里开始:
#include <...> 搜索从这里开始:
/usr/local/include
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include-fixed
/usr/include
搜索列表结束。
……
$ echo "int main() { return 0; }" > a1.cpp
$ g++ -v a1.cpp
GGC 准则:--param ggc-min-expand=100 --param ggc-min-heapsize=131072
忽略重复的目录“/usr/lib64/qt/include”
忽略不存在的目录“/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/x86_64-slackware-linux/include”
#include "..." 搜索从这里开始:
#include <...> 搜索从这里开始:
/usr/lib64/qt/include
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/4.5.2
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/4.5.2/x86_64-slackware-linux
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/4.5.2/backward
/usr/local/include
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include
/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include-fixed
/usr/include
搜索列表结束。
在eclipse中菜单Window --> Preferences --> C/C++ --> Build --> Environment添加环境变量
C_INCLUDE_PATH = /usr/local/include:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include-fixed:/usr/include
CPLUS_INCLUDE_PATH = /usr/lib64/qt/include:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/4.5.2:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/4.5.2/x86_64-slackware-linux:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/4.5.2/backward:/usr/local/include:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include:/usr/lib64/gcc/x86_64-slackware-linux/4.5.2/include-fixed:/usr/include
记得选中下面的Append variables to native environment.
添加完后再新建工程,标准库的头文件就正常了。