【问题标题】:How do I make eclipse acknowledge my include files in a C++ Existing Makefile project?如何让 eclipse 确认我在 C++ 现有 Makefile 项目中的包含文件?
【发布时间】:2012-01-18 19:58:12
【问题描述】:

简单的问题:我为现有的 makefile 配置了一个 C++ 项目,它编译得很好。但是,IDE 一直抱怨它无法解析我的大部分符号。

如何配置 eclipse 以使用我的包含?

【问题讨论】:

    标签: eclipse eclipse-cdt


    【解决方案1】:

    Project->properties->C/C++ General->Paths and Symbol

    添加包含目录的路径。

    您可以在屏幕截图中看到,我在 C++ 中使用 Qt 进行开发的配置。

    【讨论】:

    • 我这样做了,但是没有用,因为我没有使用那里列出的编译器(设置路径不会解决它)。 Eclipse 通过 makefile 编译我的项目,我不知道它到底做了什么来找出我的项目的错误 lol
    • 它是使用绝对路径而不是工作区路径来解决的。谢谢!
    【解决方案2】:

    我在路径和符号中添加了我的包含,但在 qt 编译期间未添加它们。 对于编译,qt 使用这些包含并忽略我添加的内容:

    g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/bp.o bp.cpp
    g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/Navigation.o Navigation.cpp
    Navigation.cpp:16:22: error: XnOpenNI.h: No such file or directory
    Navigation.cpp:17:26: error: XnCppWrapper.h: No such file or directory
    Navigation.cpp:18:20: error: XnHash.h: No such file or directory
    Navigation.cpp:19:19: error: XnLog.h: No such file or directory
    Navigation.cpp:22:16: error: cv.h: No such file or directory
    Navigation.cpp:23:18: error: cv.hpp: No such file or directory
    

    我在这里找到了答案: QT Eclipse Integration - Adding External Libs

    这似乎是CDT和Qt builder之间的一种冲突,所以即使你像上面截图那样在CDT中添加选项,编译器也找不到!

    您需要将它们添加到 xxx.pro 文件中,如下所示: http://doc.qt.digia.com/4.5/qmake-variable-reference.html#includepath

    【讨论】:

    • 谢谢!不过,我已经切换到 Emacs,而且我不会回头。 :)
    【解决方案3】:

    我在导入现有的 Makefile 项目时遇到了同样的问题:

    文件 -> 新建 -> 具有现有代码的 Makefile 项目

    如果您不想配置任何东西,只想让 eclipse 自己识别现有(工作)Makefile 中的所有路径,只需执行以下操作:

    • 右键单击您的项目 -> 清理项目
    • 右键单击您的项目 -> 构建项目

    Eclipse 索引器随后会自行识别所有路径,而无需任何额外配置。您只需要 Eclipse 来执行您导入的 Makefile 并且一切都已解决(如果您的 Makefile 在 Eclipse 之外正常工作)。

    测试于:

    Eclipse IDE for C/C++ Developers
    Version: Luna Service Release 2 (4.4.2)
    Build id: 20150219-0600
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-22
      • 2021-12-17
      • 2016-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多