Qt and QGis integration ERROR `__imp__ZN14QgsApplicationC1ERiPPcbRK7QStringS5_'
-
@Aman55 said in Qt and QGis integration ERROR `__imp__ZN14QgsApplicationC1ERiPPcbRK7QStringS5_':
Can you guide to compile OSGeo with MinGW?
Please refer to their documentation: https://github.com/qgis/QGIS/blob/master/INSTALL.md
-
I have downloaded visual studio 2017 and I updated my compiler with Qt Compiler MSVC 2017. got an error
C:\OSGeo4W\apps\qgis-ltr-dev\include\qgssettingsentry.h:31: error: C7525: inline variables require at least '/std:c++17' @Christian-Ehrlicher @jsulm -
@Aman55 said in Qt and QGis integration ERROR `__imp__ZN14QgsApplicationC1ERiPPcbRK7QStringS5_':
can't say yes. if it comes with download only.
You can simply check what DLLs where installed.
Does release build work? -
@jsulm Yes release build work for the above main.cpp code. currently used to load shp file and gives error
C:\OSGeo4W\apps\qgis-ltr-dev\include\qgsabstractgeometry.h:596: error: C2065: 'M_PI': undeclared identifier
C:\OSGeo4W\apps\qgis-ltr-dev\include\qgsvector.h:175: error: C2065: 'M_PI': undeclared identifier
C:\OSGeo4W\apps\qgis-ltr-dev\include\qgsgeometry.h:2757: error: C2065: 'M_PI': undeclared identifier// main.cpp int main(int argc, char *argv[]) { QApplication a(argc, argv); // 1. Initialize QGIS QgsApplication::setPrefixPath("C:/OSGeo4W64/apps/qgis-ltr-dev", true); // Replace with your QGIS installation path QgsApplication::init(); // 2. Specify the path to your SHP file QString shpFilePath = ":/gis_osm_barriers_07_1.shp"; // Replace with the actual path // 3. Check if the file exists QFileInfo fileInfo(shpFilePath); if (!fileInfo.exists()) { qDebug() << "Error: Shapefile not found at" << shpFilePath; QgsApplication::exit(); return 1; } // 4. Create a QgsVectorLayer QgsVectorLayer *vlayer = new QgsVectorLayer(shpFilePath, "shapefile_layer", "ogr"); // "ogr" is the data provider // 5. Check if the layer is valid if (!vlayer->isValid()) { qDebug() << "Error: Could not load shapefile:" << vlayer->error().message(); delete vlayer; QgsApplication::exit(); return 1; } // 6. Accessing Feature Information (Example) qDebug() << "Number of features:" << vlayer->featureCount(); // 7. Clean up delete vlayer; // Important to prevent memory leaks QgsApplication::exit(); return 0; }
-
@Aman55 Then you probably only have the release versions of these libs which can't be mixed with a debug build.
"Yes release build work for the above main.cpp code. currently used to load shp file and gives error" - I don't get it. How can it work if you get compiler errors? What is the very first error?
-
@jsulm Previously i have only use qgsapplication header as
#include <QApplication> #include <qgsapplication.h> int main(int argc, char *argv[]) { QgsApplication app(argc, argv, true); QgsApplication::setPrefixPath("C:/OSGeo4W64/apps/qgis-ltr-dev", true); int retval = app.exec(); // QgsApplication::exitQgis(); return retval; }
so there is no need for other headerfiles. then it build successfully. Now i am reading shp file where it does not locate M_PI Macro