首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包含qgis头文件时出错

包含qgis头文件时出错
EN

Stack Overflow用户
提问于 2015-03-15 16:52:58
回答 2查看 632关注 0票数 0

我正在使用QGIS API创建一个简单的qt应用程序来加载一个简单的地图或形状文件。但目前,我被包含qgis头文件所困。代码非常简单:

代码语言:javascript
复制
//
// QGIS Includes
//
#include <qgis/qgsapplication.h>
//
// Qt Includes
//
#include <QString>
#include <QApplication>
#include <QWidget>
int main(int argc, char ** argv)
{
    // Start the Application
    QgsApplication app(argc, argv, true);
    QApplication a(argc, argv);
    return app.exec();
}

我只是试着在第一步就包含qgsapplication。但是它显示了太多的错误(问题窗口中有38个错误),下面是编译输出:

代码语言:javascript
复制
15:44:09: Running steps for project Test...
15:44:09: Configuration unchanged, skipping qmake step.
15:44:09: Starting: "/usr/bin/make"
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../Test -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I/usr/include/qgis -I. -I. -I../Test -I. -o main.o ../Test/main.cpp
In file included from /usr/include/qgis/qgsapplication.h:22:0,
from ../Test/main.cpp:4:
/usr/include/qgis/qgis.h:34:19: error: variable 'CORE_EXPORT QGis' has initializer but incomplete type
class CORE_EXPORT QGis
^
/usr/include/qgis/qgis.h:34:19: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
/usr/include/qgis/qgis.h:36:3: error: expected primary-expression before 'public'
public:
^
/usr/include/qgis/qgis.h:36:3: error: expected '}' before 'public'
/usr/include/qgis/qgis.h:36:3: error: expected ',' or ';' before 'public'
/usr/include/qgis/qgis.h:42:22: error: uninitialized const 'QGIS_VERSION_INT' [-fpermissive]
static const int QGIS_VERSION_INT;
^
/usr/include/qgis/qgis.h:244:31: error: 'QGis' is not a class or namespace
static QString toLiteral( QGis::UnitType unit );
^
/usr/include/qgis/qgis.h:246:52: error: 'QGis' is not a class or namespace
static UnitType fromLiteral( QString literal, QGis::UnitType defaultType = UnknownUnit );
^
/usr/include/qgis/qgis.h:246:67: error: expected ',' or '...' before 'defaultType'
static UnitType fromLiteral( QString literal, QGis::UnitType defaultType = UnknownUnit );
^
/usr/include/qgis/qgis.h:248:24: error: 'QGis' is not a class or namespace
static QString tr( QGis::UnitType unit );
^
/usr/include/qgis/qgis.h:250:46: error: 'QGis' is not a class or namespace
static UnitType fromTr( QString literal, QGis::UnitType defaultType = UnknownUnit );
^
/usr/include/qgis/qgis.h:250:61: error: expected ',' or '...' before 'defaultType'
static UnitType fromTr( QString literal, QGis::UnitType defaultType = UnknownUnit );
^
/usr/include/qgis/qgis.h:252:41: error: 'QGis' is not a class or namespace
static double fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitType toUnit );
^
/usr/include/qgis/qgis.h:252:66: error: 'QGis' is not a class or namespace
static double fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitType toUnit );
^
/usr/include/qgis/qgis.h:252:88: error: expression list treated as compound expression in initializer [-fpermissive]
static double fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitType toUnit );
^
/usr/include/qgis/qgis.h:268:25: error: uninitialized const 'DEFAULT_IDENTIFY_RADIUS' [-fpermissive]
static const double DEFAULT_IDENTIFY_RADIUS;
^
/usr/include/qgis/qgis.h:272:25: error: uninitialized const 'DEFAULT_SEARCH_RADIUS_MM' [-fpermissive]
static const double DEFAULT_SEARCH_RADIUS_MM;
^
/usr/include/qgis/qgis.h:275:24: error: uninitialized const 'DEFAULT_MAPTOPIXEL_THRESHOLD' [-fpermissive]
static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
^
/usr/include/qgis/qgis.h:280:25: error: aggregate 'const QColor DEFAULT_HIGHLIGHT_COLOR' has incomplete type and cannot be defined
static const QColor DEFAULT_HIGHLIGHT_COLOR;
^
/usr/include/qgis/qgis.h:290:3: error: expected unqualified-id before 'private'
private:
^
/usr/include/qgis/qgis.h:294:1: error: expected declaration before '}' token
};
^
/usr/include/qgis/qgis.h:44:24: warning: 'QGIS_RELEASE_NAME' defined but not used [-Wunused-variable]
static const char* QGIS_RELEASE_NAME;
^
/usr/include/qgis/qgis.h:46:24: warning: 'QGIS_DEV_VERSION' defined but not used [-Wunused-variable]
static const char* QGIS_DEV_VERSION;
^
/usr/include/qgis/qgis.h:71:20: warning: 'WkbType singleType(WkbType)' defined but not used [-Wunused-function]
static WkbType singleType( WkbType type )
^
/usr/include/qgis/qgis.h:85:20: warning: 'WkbType multiType(WkbType)' defined but not used [-Wunused-function]
static WkbType multiType( WkbType type )
^
/usr/include/qgis/qgis.h:113:17: warning: 'bool isSingleType(WkbType)' defined but not used [-Wunused-function]
static bool isSingleType( WkbType type )
^
/usr/include/qgis/qgis.h:126:17: warning: 'bool isMultiType(WkbType)' defined but not used [-Wunused-function]
static bool isMultiType( WkbType type )
^
/usr/include/qgis/qgis.h:139:16: warning: 'int wkbDimensions(WkbType)' defined but not used [-Wunused-function]
static int wkbDimensions( WkbType type )
^
/usr/include/qgis/qgis.h:165:24: warning: 'const char* vectorGeometryType(GeometryType)' defined but not used [-Wunused-function]
static const char *vectorGeometryType( GeometryType type )
^
/usr/include/qgis/qgis.h:179:24: warning: 'const char* featureType(WkbType)' defined but not used [-Wunused-function]
static const char *featureType( WkbType type )
^
/usr/include/qgis/qgis.h:246:21: warning: 'UnitType fromLiteral(QString, int)' declared 'static' but never defined [-Wunused-function]
static UnitType fromLiteral( QString literal, QGis::UnitType defaultType = UnknownUnit );
^
/usr/include/qgis/qgis.h:250:21: warning: 'UnitType fromTr(QString, int)' declared 'static' but never defined [-Wunused-function]
static UnitType fromTr( QString literal, QGis::UnitType defaultType = UnknownUnit );
^
/usr/include/qgis/qgis.h:252:19: warning: 'fromUnitToUnitFactor' defined but not used [-Wunused-variable]
static double fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitType toUnit );
^
/usr/include/qgis/qgis.h:280:25: warning: 'DEFAULT_HIGHLIGHT_COLOR' defined but not used [-Wunused-variable]
static const QColor DEFAULT_HIGHLIGHT_COLOR;
^
/usr/include/qgis/qgis.h:284:19: warning: 'DEFAULT_HIGHLIGHT_BUFFER_MM' defined but not used [-Wunused-variable]
static double DEFAULT_HIGHLIGHT_BUFFER_MM;
^
/usr/include/qgis/qgis.h:288:19: warning: 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM' defined but not used [-Wunused-variable]
static double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM;
^
make: *** [main.o] Error 1
Makefile:220: recipe for target 'main.o' failed
15:44:10: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Test (kit: Desktop)
When executing step "Make"
15:44:10: Elapsed time: 00:01.

有人能给我一个建议吗?我的环境是OpenSUSE 13.2,QT 4.8.6,QGIS2.8。

EN

回答 2

Stack Overflow用户

发布于 2015-06-14 18:13:25

尝试使用

代码语言:javascript
复制
DEFINES += GUI_EXPORT= CORE_EXPORT=

在*.pro文件中

票数 1
EN

Stack Overflow用户

发布于 2015-03-15 16:55:13

我不知道QGis,但似乎你应该在QT包含之后添加QGis headers

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29058873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档