Simple question: I have a C++ project configured for a existing makefile and it compiles fine. However, the IDE keeps complaining that it cannot resolve most of my symbols.
简单的问题:我为一个现有的makefile配置了一个c++项目,它编译的很好。然而,IDE一直在抱怨它不能解析我的大多数符号。
How do I configure eclipse to use my includes?
如何配置eclipse以使用包含项?
3 个解决方案
#1
9
Project->properties->C/C++ General->Paths and Symbol
项目- >属性- > C / c++通用- >路径和象征
Add the path to your include directory.
将路径添加到包含目录。
You can see in the screenshot, the configuration I use to develop with Qt in C++.
您可以在屏幕截图中看到,我在c++中使用Qt开发的配置。
#2
3
I added my includes in the paths and symbols, but they are not added during qt
compilation. For compilation, qt
uses these includes and ignores what I've added:
我在路径和符号中添加了my include,但是在qt编译期间没有添加。对于编译,qt使用了这些include并忽略了我添加的内容:
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
I found the answer here: QT Eclipse Integration - Adding External Libs
我在这里找到了答案:QT Eclipse集成—添加外部Libs
It seems that this is a kind of conflict between the CDT and Qt builder, so even if you add the options in CDT as in the screenshot above, the compiler doesn't find them!
这似乎是CDT和Qt构建器之间的一种冲突,所以即使您像上面的屏幕截图那样在CDT中添加选项,编译器也找不到它们!
You need to add them in the xxx.pro file as this: http://doc.qt.digia.com/4.5/qmake-variable-reference.html#includepath
您需要在xxx中添加它们。pro文件如下:http://doc.qt.digia.com/4.5/qmake-variable-reference.html#includepath
#3
0
I had the same problem when I imported an existing Makefile project with:
当我导入一个现有的Makefile项目时遇到了同样的问题:
File -> New -> Makefile Project with Existing Code
文件->新-> Makefile项目与现有代码
If you don't want to configure anything and just want eclipse to recognize all Paths from your existing (working) Makefile on it's own just do the following:
如果您不想配置任何东西,只想让eclipse自己识别来自现有(工作)Makefile的所有路径,请执行以下操作:
- right click on your project -> Clean Project
- 右键单击您的项目->清洁项目
- right click on your project -> Build Project
- 右键单击您的项目—>构建项目
The Eclipse Indexer then recognizes all paths on it's own without needing any additional configuration. You just need Eclipse to execute your imported Makefile and everything is resolved (if your Makefile works properly outside Eclipse).
然后,Eclipse索引器识别自己的所有路径,而不需要任何附加配置。您只需要Eclipse来执行导入的Makefile,一切都得到解决(如果您的Makefile在Eclipse之外正常工作)。
Tested in:
测试:
Eclipse IDE for C/C++ Developers
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600
#1
9
Project->properties->C/C++ General->Paths and Symbol
项目- >属性- > C / c++通用- >路径和象征
Add the path to your include directory.
将路径添加到包含目录。
You can see in the screenshot, the configuration I use to develop with Qt in C++.
您可以在屏幕截图中看到,我在c++中使用Qt开发的配置。
#2
3
I added my includes in the paths and symbols, but they are not added during qt
compilation. For compilation, qt
uses these includes and ignores what I've added:
我在路径和符号中添加了my include,但是在qt编译期间没有添加。对于编译,qt使用了这些include并忽略了我添加的内容:
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
I found the answer here: QT Eclipse Integration - Adding External Libs
我在这里找到了答案:QT Eclipse集成—添加外部Libs
It seems that this is a kind of conflict between the CDT and Qt builder, so even if you add the options in CDT as in the screenshot above, the compiler doesn't find them!
这似乎是CDT和Qt构建器之间的一种冲突,所以即使您像上面的屏幕截图那样在CDT中添加选项,编译器也找不到它们!
You need to add them in the xxx.pro file as this: http://doc.qt.digia.com/4.5/qmake-variable-reference.html#includepath
您需要在xxx中添加它们。pro文件如下:http://doc.qt.digia.com/4.5/qmake-variable-reference.html#includepath
#3
0
I had the same problem when I imported an existing Makefile project with:
当我导入一个现有的Makefile项目时遇到了同样的问题:
File -> New -> Makefile Project with Existing Code
文件->新-> Makefile项目与现有代码
If you don't want to configure anything and just want eclipse to recognize all Paths from your existing (working) Makefile on it's own just do the following:
如果您不想配置任何东西,只想让eclipse自己识别来自现有(工作)Makefile的所有路径,请执行以下操作:
- right click on your project -> Clean Project
- 右键单击您的项目->清洁项目
- right click on your project -> Build Project
- 右键单击您的项目—>构建项目
The Eclipse Indexer then recognizes all paths on it's own without needing any additional configuration. You just need Eclipse to execute your imported Makefile and everything is resolved (if your Makefile works properly outside Eclipse).
然后,Eclipse索引器识别自己的所有路径,而不需要任何附加配置。您只需要Eclipse来执行导入的Makefile,一切都得到解决(如果您的Makefile在Eclipse之外正常工作)。
Tested in:
测试:
Eclipse IDE for C/C++ Developers
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600