• Eclipse CDT 配置C /C ++ 标准库 (UBUNTU 12 )


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

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

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

    $ gcc -v a1.c

    #include "..." 搜索从这里开始:
    #include <...> 搜索从这里开始:

     /usr/lib/gcc/i686-linux-gnu/4.6.1/include
     /usr/local/include
     /usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
     /usr/include/i386-linux-gnu
     /usr/include

    搜索列表结束。

    ……

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

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

    $ g++ -v a1.cpp

    #include "..." 搜索从这里开始:
    #include <...> 搜索从这里开始:
     /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.1/include
     /usr/local/include
     /usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
     /usr/include/i386-linux-gnu
     /usr/include
    搜索列表结束。

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

    C_INCLUDE_PATH =/usr/lib/gcc/i686-linux-gnu/4.6.1/include:/usr/local/include:/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed:/usr/include/i386-linux-gnu:/usr/include

    CPLUS_INCLUDE_PATH =/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.1/include:/usr/local/include:/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed:/usr/include/i386-linux-gnu:/usr/include

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

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

    eclipse上配置好cdt后,新建一个简单的项目测试下,当写入头文件时,却出现如下错误提示:

    unresolved inclusion: <stdio.h>

    原因与解决:

    这是c/c++标准库未设置所致。解决方法如下。

    选中项目,依次操作:

    右键单击 -> properties -> C/C++ General -> Paths and Symbols -> Add...  -> file system.

    然后选择c/c++库的位置:/usr/include

    如此再继续添加/usr/include/c++路径。确定后即可

    参考:

    Eclipse reports Unresolved inclusion for system headers such as stdio.h if it cannot locate the header files for a project. You can resolve this by right-clicking on the project in the Project Explorer view and then selecting Properties... from the context menu. In the dialog box, select: C/C++ General → Paths and Symbols → Add... and then add the path to the ARM Compiler headers on your host workstation. For example, C:\Program Files\DS-5\include. Select both Add to all configurations and Add to all languages, click on Apply so that Eclipse can rebuild the index.

  • 相关阅读:
    点击图片跳转详情
    offsetwidth/clientwidth的区别
    css中让元素隐藏的多种方法
    js中的||、&&与!用法
    怎么区分静态网页和动态网页
    我的第一篇博客--新手勿喷
    2015腾讯暑期实习生面试
    ring0 与 ring3 层之间的交互
    驱动层得到进程的完整路径
    WinDbg调试流程的学习及对TP反调试的探索
  • 原文地址:https://www.cnblogs.com/dongxiaoguang/p/2910870.html
Copyright © 2020-2023  润新知