2015-03-15 2 views
0

Я работаю над созданием простого приложения qt с использованием QGIS API для загрузки простого файла карты или формы. Но в настоящее время я застрял, включая файлы заголовков qgis. Код очень прост:Ошибка при включении файлов заголовков qgis

// 
// 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 ошибок в окне вопросов), а вот выход компиляции:

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, QGIS 2.8.

+0

В отличие от сайтов форума, мы не используем «Спасибо» или «Любая помощь приветствуется», или подписи на [так]. См. «[Должны ли« Привет »,« спасибо », теги и приветствия удалены из сообщений?] (Http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be «Спасибо, заранее», а не «Спасибо в продвинутом». –

ответ

0

Я не знаю QGis, но, похоже, вы должны #include заголовки QGis после QT.

+0

Спасибо. Я пробовал, но он не работает. Есть ли у вас какие-либо другие идеи? – nguyenhieu008

+0

только для просмотра другого кода который использует QGis. Там есть какой-то открытый исходный код, который делает! –

+0

https://github.com/qgis/QGIS-Code-Examples Я скопировал код оттуда. Нет руководства для установки среды. первый пример кода и упростить его (просто включите только заголовок) .Но он не работает. – nguyenhieu008

Смежные вопросы