QGIS cannot find headers file

854 views Asked by At

I'm trying to create a custom QGIS desktop application with Qt 5.9.1

I have downloaded OSGeo4W (x64) geospatial software set and the Github C++ QGIS samples but I'm facing an error at compile time:

Cannot open include file: 'qgsmapcanvas.h': No such file or directory

Actually none of the above headers files are under OSGeo4W folder:

#include <qgsapplication.h>
#include <qgsproviderregistry.h>
#include <qgssinglesymbolrenderer.h>
#include <qgsmaplayerregistry.h>
#include <qgsrasterlayer.h>
#include <qgsmapcanvas.h>

But..shouldn't they be in dll libraries (eg qgis_core, qgis_gui ... ) ?

Anyway, this is my *.pro file:

TEMPLATE = app
TARGET = qgis_example4
QT = sql network svg gui core xml
LANGUAGE= C++

INCLUDEPATH +=  "C:\\OSGeo4W64\\include"

LIBS += -L"C:\\OSGeo4W64\\apps\\qgis\\bin" -lqgis_core -lqgis_gui -lgdal_i -lgeos_c

DEFINES+=CORE_EXPORT=__declspec(dllexport)
DEFINES+=GUI_EXPORT=__declspec(dllexport)

CONFIG += qt gui exceptions stl warn_on debug thread

RESOURCES += resources.qrc

FORMS += mainwindowbase.ui

HEADERS = mainwindow.h

SOURCES = main.cpp \
              mainwindow.cpp

PS: there is a similar question on stackiverflow but I repeated it because the answers given did not give the solution

1

There are 1 answers

0
Andrea D'Ubaldo On

Solved: the needed headers file could be found within the "qgis-dev" branch of the project.

OSGeo4W : For users that cannot use OSGeo4W for some reason or just prefer it there is also a weekly snapshot of qgis-dev from OSGeo4W as standalone installer

After the installation you can find header in:

C:/Program Files/QGIS 2.99/apps/qgis-dev/include

So this is my .pro file

TEMPLATE = app
TARGET = qgis_example4
QT = sql network svg gui core xml
LANGUAGE= C++


INCLUDEPATH += "C:/Program Files/QGIS 2.99/include"
INCLUDEPATH += "C:/Program Files/QGIS 2.99/apps/qgis-dev/include"

LIBS += -L"C:/Program Files/QGIS 2.99/apps/qgis-dev/bin" -lqgis_core -lqgis_gui

DEFINES+=CORE_EXPORT=__declspec(dllexport)
DEFINES+=GUI_EXPORT=__declspec(dllexport)

CONFIG += qt gui exceptions stl warn_on debug thread

RESOURCES += resources.qrc

FORMS += mainwindowbase.ui

HEADERS = mainwindow.h

SOURCES = main.cpp \
          mainwindow.cpp

Although the files are now present, I still not able to run QGIS samples. Maybe I'll move to other sample or I'll do my custom basic application.