找不到qgsapplication.h和其他头文件

时间:2014-11-13 23:43:58

标签: c++ qt qgis

我正在使用QtCreator和QGIS 2.6构建一个独立的C ++应用程序。

我遇到的问题是项目无法找到所有必需的头文件。

我的.pro文件看起来如下:

QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestQgis2
TEMPLATE = app
SOURCES += main.cpp
#HEADERS +=YOUR HEADERS
#FORMS += YOUR FORMS
#RESOURCES += images/images.qrc

win32:CONFIG(Release, Debug|Release) {
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/lib/" -lQtCore4
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/lib/" -lQtGui4
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/lib/" -lQtXml4
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/apps/qgis/bin/" -lqgis_core
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/apps/qgis/bin/" -lqgis_gui
}
else:win32:CONFIG(Debug, Debug|Release) {
 PRE_TARGETDEPS += C:/Program Files (x86)/QGIS Brighton/lib/QtCored4.lib
 PRE_TARGETDEPS += C:/Program Files (x86)/QGIS Brighton/lib/QtGuid4.lib
 PRE_TARGETDEPS += C:/Program Files (x86)/QGIS Brighton/lib/QtXmld4.lib
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/lib/" -lQtCored4
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/lib/" -lQtGuid4
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/lib/" -lQtXmld4
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/apps/qgis/bin/" -lqgis_core
 LIBS += -L"C:/Program Files (x86)/QGIS Brighton/apps/qgis/bin/" -lqgis_gui
}
win32:{
 INCLUDEPATH += C:/Program Files (x86)/QGIS Brighton/include
 DEPENDPATH +=  C:/Program Files (x86)/QGIS Brighton/include
# INCLUDEPATH += C:/OSGeo4W/apps/qgis-dev/include
# DEPENDPATH += C:/OSGeo4W/apps/qgis-dev/include
 DEFINES += GUI_EXPORT=__declspec(dllimport) CORE_EXPORT=__declspec(dllimport)
}
unix {
 LIBS += -L/usr/local/lib/ -lqgis_core -lqgis_gui
 LIBS += -L/usr/local/lib/qgis/plugins/ -lgdalprovider
 INCLUDEPATH += /usr/local/include/qgis
 DEFINES += GUI_EXPORT= CORE_EXPORT=
}

在我的程序中,找不到以下标头:      

#include"<" qgsapplication.h">"

     

#include"<" qgsproviderregistry.h">"

     

#include"<" qgssinglesymbolrenderer.h">"

     

#include"<" qgsmaplayerregistry.h">"

     

#include"<" qgsvectorlayer.h">"

     

#include"<" qgsmapcanvas.h">"

从已安装的qgis文件夹中,我找不到上述任何头文件。

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

要调试应用程序,我认为您必须在项目文件中添加RelWithDebInfo模式:

QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestQgis2
TEMPLATE = app
SOURCES += main.cpp
#HEADERS +=YOUR HEADERS
#FORMS += YOUR FORMS
#RESOURCES += images/images.qrc

win32:CONFIG(Release, Debug|Release, RelWithDebInfo) {
 LIBS += -L"C:/OSGeo4W/apps/qgis/lib/" -lQtCore4
 LIBS += -L"C:/OSGeo4W/apps/qgis/lib/" -lQtGui4
 LIBS += -L"C:/OSGeo4W/apps/qgis/lib/" -lQtXml4
 LIBS += -L"C:/OSGeo4W/apps/qgis/bin/" -lqgis_core
 LIBS += -L"C:/OSGeo4W/apps/qgis/bin/" -lqgis_gui
}
else:win32:CONFIG(Debug, Debug|Release, RelWithDebInfo) {
 PRE_TARGETDEPS += C:/OSGeo4W/lib/QtCored4.lib
 PRE_TARGETDEPS += C:/OSGeo4W/lib/QtGuid4.lib
 PRE_TARGETDEPS += C:/OSGeo4W/lib/QtXmld4.lib
 LIBS += -L"C:/OSGeo4W/lib/" -lQtCored4
 LIBS += -L"C:/OSGeo4W/lib/" -lQtGuid4
 LIBS += -L"C:/OSGeo4W/lib/" -lQtXmld4
 LIBS += -L"C:/OSGeo4W/apps/qgis/bin/" -lqgis_core
 LIBS += -L"C:/OSGeo4W/apps/qgis/bin/" -lqgis_gui
}
win32:{
 INCLUDEPATH += C:/OSGeo4W/include
 DEPENDPATH +=  C:/OSGeo4W/include
# INCLUDEPATH += C:/OSGeo4W/apps/qgis/include
# DEPENDPATH += C:/OSGeo4W/apps/qgis/include
 DEFINES += GUI_EXPORT=__declspec(dllimport) CORE_EXPORT=__declspec(dllimport)
}
unix {
 LIBS += -L/usr/local/lib/ -lqgis_core -lqgis_gui
 LIBS += -L/usr/local/lib/qgis/plugins/ -lgdalprovider
 INCLUDEPATH += /usr/local/include/qgis
 DEFINES += GUI_EXPORT= CORE_EXPORT=
}

答案 1 :(得分:0)

哪一个是第28行?

如果是这样的话:

win32:CONFIG(Release, Debug|Release, RelWithDebInfo)

您可以将其替换为:

win32:CONFIG(Release, RelWithDebInfo|Release)

并替换它:

else:win32:CONFIG(Debug, Debug|Release, RelWithDebInfo)

使用:

else:win32:CONFIG(RelWithDebInfo, RelWithDebInfo|Release)

因为Qgis ant Qt库是使用Release模式编译的,所以如果你想调试应用程序,你必须使用RelWithDebInfo模式