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 714 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 31 Jan 2025, 08:11 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

    J 1 Reply Last reply 31 Jan 2025, 08:18
    0
    • A Aman55
      31 Jan 2025, 08:11

      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

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 31 Jan 2025, 08:18 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 31 Jan 2025, 08:23
      0
      • J jsulm
        31 Jan 2025, 08:18

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

        A Offline
        A Offline
        Aman55
        wrote on 31 Jan 2025, 08:23 last edited by
        #8

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

        J 1 Reply Last reply 31 Jan 2025, 08:28
        0
        • A Aman55
          31 Jan 2025, 08:23

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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 31 Jan 2025, 08:28 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 31 Jan 2025, 08:45
          0
          • J jsulm
            31 Jan 2025, 08:28

            @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 31 Jan 2025, 08:45 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;
            }
            
            J 1 Reply Last reply 31 Jan 2025, 08:53
            0
            • A Aman55
              31 Jan 2025, 08:45

              @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;
              }
              
              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 31 Jan 2025, 08:53 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 31 Jan 2025, 09:00 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 31 Jan 2025, 09:23 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>

                  J 1 Reply Last reply 31 Jan 2025, 11:43
                  0
                  • A Aman55
                    31 Jan 2025, 09:23

                    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>

                    J Offline
                    J Offline
                    JonB
                    wrote on 31 Jan 2025, 11:43 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 1 Feb 2025, 04:41
                    0
                    • J JonB
                      31 Jan 2025, 11:43

                      @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 1 Feb 2025, 04:41 last edited by Aman55 2 Jan 2025, 04:43
                      #15

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

                      J 1 Reply Last reply 1 Feb 2025, 09:53
                      0
                      • A Aman55
                        1 Feb 2025, 04:41

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

                        J Offline
                        J Offline
                        JonB
                        wrote on 1 Feb 2025, 09:53 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

                        15/16

                        1 Feb 2025, 04:41

                        • Login

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