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. QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget')

QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget')

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
13 Posts 5 Posters 878 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.
  • C Offline
    C Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 25 Nov 2024, 07:20 last edited by
    #4

    Since I don't use neither QGis nor qmake - not really.
    As you can see you link against a lot of qgis libraries, but not against the gui module - add it.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    X 1 Reply Last reply 25 Nov 2024, 07:34
    2
    • C Christian Ehrlicher
      25 Nov 2024, 07:20

      Since I don't use neither QGis nor qmake - not really.
      As you can see you link against a lot of qgis libraries, but not against the gui module - add it.

      X Offline
      X Offline
      xanthas
      wrote on 25 Nov 2024, 07:34 last edited by
      #5

      @Christian-Ehrlicher If I have understood correctly, you meant that I should link library related gui module of QGiS. Can you please let me know how to do it
      Or else I haven't understoor properly what you meant. Can you please elaborate the suggestion or solution you provided

      @Christian-Ehrlicher said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

      As you can see you link against a lot of qgis libraries, but not against the gui module - add it.

      J 1 Reply Last reply 25 Nov 2024, 08:30
      0
      • X xanthas
        25 Nov 2024, 07:34

        @Christian-Ehrlicher If I have understood correctly, you meant that I should link library related gui module of QGiS. Can you please let me know how to do it
        Or else I haven't understoor properly what you meant. Can you please elaborate the suggestion or solution you provided

        @Christian-Ehrlicher said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

        As you can see you link against a lot of qgis libraries, but not against the gui module - add it.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 25 Nov 2024, 08:30 last edited by
        #6

        @xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

        Can you please let me know how to do it

        Come on - you already link many libraries - what is the problem to add one more?

        LIBS += C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_3d.lib \
                C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_analysis.lib \
                C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_app.lib \
                C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_native.lib \
                C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_server.lib \
                ADD_HERE_THEGUI_ONE
        

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

        X 2 Replies Last reply 25 Nov 2024, 10:04
        0
        • J jsulm
          25 Nov 2024, 08:30

          @xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

          Can you please let me know how to do it

          Come on - you already link many libraries - what is the problem to add one more?

          LIBS += C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_3d.lib \
                  C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_analysis.lib \
                  C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_app.lib \
                  C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_native.lib \
                  C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_server.lib \
                  ADD_HERE_THEGUI_ONE
          
          X Offline
          X Offline
          xanthas
          wrote on 25 Nov 2024, 10:04 last edited by xanthas
          #7

          @jsulm Sorry to be a little annoying here
          For me its a bit difficult to understand programming in qt so that's why I asked.
          Thank you for the solution
          I will try and update here

          By the way is there any way I can have the drag and drop option in design area for qgis in the creator itself?

          1 Reply Last reply
          0
          • J jsulm
            25 Nov 2024, 08:30

            @xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

            Can you please let me know how to do it

            Come on - you already link many libraries - what is the problem to add one more?

            LIBS += C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_3d.lib \
                    C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_analysis.lib \
                    C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_app.lib \
                    C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_native.lib \
                    C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_server.lib \
                    ADD_HERE_THEGUI_ONE
            
            X Offline
            X Offline
            xanthas
            wrote on 25 Nov 2024, 10:57 last edited by
            #8

            @jsulm

            .pro File now includes
                C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_gui.lib \
                C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_core.lib
            

            Still the same error
            There can be issue because of the admin permission? But I have installed for ALL Users

            J 1 Reply Last reply 25 Nov 2024, 13:28
            0
            • X xanthas
              25 Nov 2024, 10:57

              @jsulm

              .pro File now includes
                  C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_gui.lib \
                  C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_core.lib
              

              Still the same error
              There can be issue because of the admin permission? But I have installed for ALL Users

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 25 Nov 2024, 13:28 last edited by
              #9

              @xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

              There can be issue because of the admin permission?

              No

              Did you do a complete rebuild after changing pro file?

              1. Delete build folder
              2. Run qmake
              3. Build

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

              X 1 Reply Last reply 26 Nov 2024, 05:38
              1
              • J jsulm
                25 Nov 2024, 13:28

                @xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):

                There can be issue because of the admin permission?

                No

                Did you do a complete rebuild after changing pro file?

                1. Delete build folder
                2. Run qmake
                3. Build
                X Offline
                X Offline
                xanthas
                wrote on 26 Nov 2024, 05:38 last edited by
                #10

                @jsulm I tried it just before typing this reply. Also, since last night I have been trying to contact a few friends of mine who have been working with Qt for a while. The conclusion I have got to is that, this problem lies in QGiS and not with Qt. Also, I can't find answers as there are no tutorials related to QGiS Qt C++ programming. I have asked the same query in their forum as well.

                J 1 Reply Last reply 26 Nov 2024, 08:15
                0
                • X xanthas
                  26 Nov 2024, 05:38

                  @jsulm I tried it just before typing this reply. Also, since last night I have been trying to contact a few friends of mine who have been working with Qt for a while. The conclusion I have got to is that, this problem lies in QGiS and not with Qt. Also, I can't find answers as there are no tutorials related to QGiS Qt C++ programming. I have asked the same query in their forum as well.

                  J Online
                  J Online
                  JonB
                  wrote on 26 Nov 2024, 08:15 last edited by JonB
                  #11

                  @xanthas
                  I don't use QGIS or Windows. But a little searching and reading implies to me:

                  • In your stackexchange post I think you do, or might, need to add the qgis_core and qgis_gui libraries. Unless the other libraries use an MSVC feature which auto-adds them.

                  • Make sure that both QGIS and your code are built using the same compiler. I don't know whether you are compiling QGIS yourself or which compiler you are using. It is clearly intended for MSVC, so make sure you are not using MinGW. Make sure you use the same version of MSVC for both.

                  • I have a feeling/hope that you may need to add a couple of DEFINES which you are not doing. In your .pro I believe you should have one of

                  DEFINES += CORE_EXPORT=
                  DEFINES += GUI_EXPORT=
                  

                  or

                  DEFINES += CORE_EXPORT=__declspec(dllimport)
                  DEFINES += GUI_EXPORT=__declspec(dllimport)
                  

                  (possibly the latter). This is an MSVC-ism. Try both (rebuild your code from scratch each time), does it work after e.g. the second pair of definitions?

                  References:
                  https://gis.stackexchange.com/questions/244373/qt-c-application-using-qgis-api/246218#246218
                  https://stackoverflow.com/questions/42201632/qgis-with-standalone-c-application-in-qt-creator
                  https://3nids.wordpress.com/

                  X 1 Reply Last reply 5 Dec 2024, 07:17
                  0
                  • X xanthas referenced this topic on 3 Dec 2024, 11:33
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 3 Dec 2024, 21:29 last edited by
                    #12

                    Hi,

                    Why not use the standard notation:

                    LIBS += -LC:/OSGeo4W/apps/qgis-qt6-dev/lib \
                        -lqgis_gui \
                        -lqgis_core
                    

                    ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • J JonB
                      26 Nov 2024, 08:15

                      @xanthas
                      I don't use QGIS or Windows. But a little searching and reading implies to me:

                      • In your stackexchange post I think you do, or might, need to add the qgis_core and qgis_gui libraries. Unless the other libraries use an MSVC feature which auto-adds them.

                      • Make sure that both QGIS and your code are built using the same compiler. I don't know whether you are compiling QGIS yourself or which compiler you are using. It is clearly intended for MSVC, so make sure you are not using MinGW. Make sure you use the same version of MSVC for both.

                      • I have a feeling/hope that you may need to add a couple of DEFINES which you are not doing. In your .pro I believe you should have one of

                      DEFINES += CORE_EXPORT=
                      DEFINES += GUI_EXPORT=
                      

                      or

                      DEFINES += CORE_EXPORT=__declspec(dllimport)
                      DEFINES += GUI_EXPORT=__declspec(dllimport)
                      

                      (possibly the latter). This is an MSVC-ism. Try both (rebuild your code from scratch each time), does it work after e.g. the second pair of definitions?

                      References:
                      https://gis.stackexchange.com/questions/244373/qt-c-application-using-qgis-api/246218#246218
                      https://stackoverflow.com/questions/42201632/qgis-with-standalone-c-application-in-qt-creator
                      https://3nids.wordpress.com/

                      X Offline
                      X Offline
                      xanthas
                      wrote on 5 Dec 2024, 07:17 last edited by
                      #13

                      @JonB Hi these I have already included.
                      Also, I have seen a few examples at Github. I have tried to compile with MSVC as well as MinGW.
                      These are the errors:

                      moc_india_map_test.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QgsVectorLayer::staticMetaObject" (?staticMetaObject@QgsVectorLayer@@2UQMetaObject@@B)
                      moc_india_map_test.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QgsRasterLayer::staticMetaObject" (?staticMetaObject@QgsRasterLayer@@2UQMetaObject@@B)
                      

                      after I try to run the project.

                      1 Reply Last reply
                      0

                      13/13

                      5 Dec 2024, 07:17

                      • Login

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