Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qt and QGis integration ERROR `__imp__ZN14QgsApplicationC1ERiPPcbRK7QStringS5_'
Forum Updated to NodeBB v4.3 + New Features

Qt and QGis integration ERROR `__imp__ZN14QgsApplicationC1ERiPPcbRK7QStringS5_'

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
16 Posts 4 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aman55
    wrote on last edited by Aman55
    #5

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Aman55
      wrote on last edited by
      #6

      update c++11 to c++17 and build successfully . but 13:39:44: The program has unexpectedly finished. when i run in debug mode it giving ![alt Screenshot (6).png

      jsulmJ 1 Reply Last reply
      0
      • A Aman55

        update c++11 to c++17 and build successfully . but 13:39:44: The program has unexpectedly finished. when i run in debug mode it giving ![alt Screenshot (6).png

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @Aman55 Do you have the debug versions of the QGIS libs?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Aman55 Do you have the debug versions of the QGIS libs?

          A Offline
          A Offline
          Aman55
          wrote on last edited by
          #8

          @jsulm can't say yes. if it comes with download only.

          jsulmJ 1 Reply Last reply
          0
          • A Aman55

            @jsulm can't say yes. if it comes with download only.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #9

            @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?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply
            0
            • jsulmJ 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?

              A Offline
              A Offline
              Aman55
              wrote on last edited by
              #10

              @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;
              }
              
              jsulmJ 1 Reply Last reply
              0
              • A Aman55

                @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;
                }
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #11

                @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?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  Aman55
                  wrote on last edited by Aman55
                  #12

                  @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

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Aman55
                    wrote on last edited by Aman55
                    #13

                    it build successfully but giving some runtime error unable to pinpoint as it only gives The program has unexpectedly finished. After including #include <qgsapplication.h>

                    JonBJ 1 Reply Last reply
                    0
                    • A Aman55

                      it build successfully but giving some runtime error unable to pinpoint as it only gives The program has unexpectedly finished. After including #include <qgsapplication.h>

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #14

                      @Aman55 So far as I can see you have not tried to show the stack trace from a debugger when it crashes.

                      A 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Aman55 So far as I can see you have not tried to show the stack trace from a debugger when it crashes.

                        A Offline
                        A Offline
                        Aman55
                        wrote on last edited by Aman55
                        #15

                        @JonB In debug mode i got error of CDB process terminatedScreenshot (7).png

                        JonBJ 1 Reply Last reply
                        0
                        • A Aman55

                          @JonB In debug mode i got error of CDB process terminatedScreenshot (7).png

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #16

                          @Aman55 Yes, you need to look at the stack trace pane in the debugger when that happens, so that you know where it comes from.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved