I'm trying to create a simple application using QGIS 3 SDK. I have used osgeo4w-setup-x86_64.exe for installing QGIS, and I have also installed qgis-dev and qgis-ltr-dev and Qt5. I have set up my .pro file like this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
INCLUDEPATH += "C:\OSGeo4W64\apps\qgis-ltr-dev\include" \
"C:\OSGeo4W64\apps\qgis-ltr-dev\bin"
LIBS += -L"C:\OSGeo4W64\apps\qgis-ltr-dev\lib" -lqgis_core -lqgis_gui -lqgis_app
SOURCES += \
main.cpp
and the main.cpp is like this:
#include <qgsapplication.h>
#include <QDebug>
int main(int argc, char *argv[])
{
qDebug() << "*** QGS Application Instance Created *** ";
QgsApplication app(argc, argv, true);
int exitCode= app.exec();
return exitCode;
}
I run my code in this enviroment:
Windows 10
Qt 5.15.1(MSVC 2019)
Qt Creator 4.13.1
QGIS 3.x.x
This code is compiled correctly. But, the problem is when I run it, the program crash even before entering the main function. When I comment the line QgsApplication app(argc, argv, true);
, the crash does not happen. I believe there is some problem with linking the QGIS to my application.
How can I fix this?
Have I done something wrong?
Haven't I considered something in setting up the environment?