2

I'm trying to create a simple application using QGIS SDK. But currently, I'm stuck with API at very beginning stage.

belows are the env.

Windows 7

MSVC 2015

QGIS SDK (downlaod by OSGeo4w) include: qgis-dev(3.2.3) Qt5(5.9)

here is the OSGeo4W directory

here is the OSGeo4W-app directory

And start by create an empty project, property settings:

C/C++ -> General -> Additional Include Directories

C:\OSGeo4W\apps\Qt5\include
C:\OSGeo4W\apps\Qt5\include\QtCore
C:\OSGeo4W\apps\Qt5\include\QtGui
C:\OSGeo4W\apps\Qt5\include\QtWidgets
C:\OSGeo4W\apps\Qt5\include\QtXml
C:\OSGeo4W\apps\qgis-dev\include
C:\OSGeo4W\include

Linker -> General -> Additional Library Directories

C:\OSGeo4W\apps\Qt5\lib
C:\OSGeo4W\apps\qgis-dev\lib

Linker -> Input -> Additional Dependencies

qtmaind.lib
Qt5Cored.lib
Qt5Guid.lib
Qt5Widgetsd.lib
qgis_core.lib
qgis_app.lib
qgis_gui.lib

The test code is quite simple:

main.cpp

#include <QtWidgets/QApplication>
#include <qgsapplication.h>

int main(int argc, char *argv[])
{
     QgsApplication a(argc, argv, true);
 //  QgsApplication::setPrefixPath("C:/path/to/OSGeo4W64/apps/qgis", true);
 //  QgsApplication::initQgis();
 //  ImageViewer w; 
 //  w.show();

     return a.exec(); 
}

however, errors occured when I build it,

(1)no instance of constructor "QgsMapUnitScale::QgsMapUnitScale" matches the argument list (qgsrendercontext.h)

(2)"M_PI": undeclared identifier (qgsabstractgeometry.h)

here is the build errors

Could anyone give me a suggestion?

I have some difficulties to understand how the API should work and there is really few doc. and resource about QGIS C++ developement on internet, even on QGIS offical website.

  • 2
    Developing QGIS plugins in C++ is discouraged which would be why there is limited documentation... there is some logic to this, making your own branch is no problem but your plugin development stops with you then the next time there's an update your version is out-of-date and you have to redo all your changes again to get the benefit of the update. I think it would be nice to have this capability, or C# even, but this decision was made early on in the QGIS project and doesn't look like changing soon. – Michael Stimson Oct 19 '18 at 4:31
0

For the "M_PI": undeclared identifier (qgsabstractgeometry.h) just go the the header file and add #define M_PI 3.14159265359 below the #include files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.