Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGiS Windows Source Build
Forum Updated to NodeBB v4.3 + New Features

QGiS Windows Source Build

Scheduled Pinned Locked Moved Unsolved General and Desktop
42 Posts 7 Posters 7.5k Views 1 Watching
  • 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.
  • X xanthas

    Hello Community,
    I’ve been working with Qt Creator 6 and PyQt5, but recently I needed to use QGIS for map functionality. While attempting to build a simple UI for Windows, I ran into several errors and warning messages during the process. Despite following the Building on Windows guide and trying out the example files from code_examples as well as the Quantum GIS Coding and Compilation Guide, I still encountered issues.

    My .pro files look like this:

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++17
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        mainwindow.cpp
    
    HEADERS += \
        mainwindow.h
    
    FORMS += \
        mainwindow.ui
    
    INCLUDEPATH += C:\OSGeo4W\QGIS\src\app C:\OSGeo4W\apps\qgis-qt6-dev\include C:\OSGeo4W\include C:\OSGeo4W\apps\Qt6\include #C:\OSGeo4W\QGIS\src\core C:\OSGeo4W\apps\qgis-dev\include
    
    LIBS += -L"C:\OSGeo4W\apps\qgis-qt6-dev\lib" -lqgis_gui -lqgis_core
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    my osgeo4w-build folder and QGIS (git clone) are present inside C:\OSGeo4W location
    Please help me !!!

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

    @xanthas said in QGiS Windows Source Build:

    I still encountered issues

    Please also tell us what issues...

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

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xanthas
      wrote on last edited by
      #3

      It gives around 27 different errors like:

      :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:24: undefined reference to `__imp__ZN19QgsProviderRegistry8instanceERK7QString'
      :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:27: undefined reference to `__imp__ZN14QgsVectorLayerC1ERK7QStringS2_S2_RKNS_12LayerOptionsE'
      :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:30: undefined reference to `__imp__ZNK11QgsMapLayer7isValidEv'
      :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:36: undefined reference to `__imp__ZNK14QgsVectorLayer12geometryTypeEv'
      C:\OSGeo4W\apps\qgis-qt6-dev\include\qgis.h:611: error: undefined reference to `__imp__ZN4Qgis16staticMetaObjectE'
      :-1: error: [Makefile.Debug:72: debug/simpleqgistest.exe] Error 1
      

      And many other such errors

      jsulmJ 1 Reply Last reply
      0
      • X xanthas

        It gives around 27 different errors like:

        :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:24: undefined reference to `__imp__ZN19QgsProviderRegistry8instanceERK7QString'
        :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:27: undefined reference to `__imp__ZN14QgsVectorLayerC1ERK7QStringS2_S2_RKNS_12LayerOptionsE'
        :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:30: undefined reference to `__imp__ZNK11QgsMapLayer7isValidEv'
        :-1: error: C:\Users\D Besta\Documents\simpleqgistest\build\Desktop_Qt_6_6_3_MinGW_64_bit-Debug/../../main.cpp:36: undefined reference to `__imp__ZNK14QgsVectorLayer12geometryTypeEv'
        C:\OSGeo4W\apps\qgis-qt6-dev\include\qgis.h:611: error: undefined reference to `__imp__ZN4Qgis16staticMetaObjectE'
        :-1: error: [Makefile.Debug:72: debug/simpleqgistest.exe] Error 1
        

        And many other such errors

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

        @xanthas You're not linking the libraries properly.
        On Windows this is wrong:

        LIBS += -L"C:\OSGeo4W\apps\qgis-qt6-dev\lib" -lqgis_gui -lqgis_core
        

        Please take a look at https://doc.qt.io/qt-6/qmake-variable-reference.html#libs and fix this.

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

        X 1 Reply Last reply
        0
        • jsulmJ jsulm

          @xanthas You're not linking the libraries properly.
          On Windows this is wrong:

          LIBS += -L"C:\OSGeo4W\apps\qgis-qt6-dev\lib" -lqgis_gui -lqgis_core
          

          Please take a look at https://doc.qt.io/qt-6/qmake-variable-reference.html#libs and fix this.

          X Offline
          X Offline
          xanthas
          wrote on last edited by
          #5

          @jsulm
          a62b5b3a-2577-469d-b589-07d06b50bafc-image.png

          I have edited the .pro file to:

          LIBS += -L"C:\OSGeo4W\apps\qgis-qt6-dev\lib libs" -lqgis_gui -lqgis_core
          

          I also tried:

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

          The file seems to be there but after what you said suggested it is giving me only this error now:

          C:\Qt\Tools\mingw1120_64\x86_64-w64-mingw32\bin\ld.exe:-1: cannot find -lqgis_gui
          C:\Qt\Tools\mingw1120_64\x86_64-w64-mingw32\bin\ld.exe:-1: cannot find -lqgis_core
          

          When I did this:

          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 #-lqgis_gui -lqgis_core
          

          Again all the previous errors mentioned arise

          jsulmJ 1 Reply Last reply
          0
          • X xanthas

            @jsulm
            a62b5b3a-2577-469d-b589-07d06b50bafc-image.png

            I have edited the .pro file to:

            LIBS += -L"C:\OSGeo4W\apps\qgis-qt6-dev\lib libs" -lqgis_gui -lqgis_core
            

            I also tried:

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

            The file seems to be there but after what you said suggested it is giving me only this error now:

            C:\Qt\Tools\mingw1120_64\x86_64-w64-mingw32\bin\ld.exe:-1: cannot find -lqgis_gui
            C:\Qt\Tools\mingw1120_64\x86_64-w64-mingw32\bin\ld.exe:-1: cannot find -lqgis_core
            

            When I did this:

            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 #-lqgis_gui -lqgis_core
            

            Again all the previous errors mentioned arise

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

            @xanthas

            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
            

            Should work (you have \ in the paths which is wrong, don't use \ in in paths in pro files ).
            If it does not then next thing to check is: were these libs built using same compiler?
            You should also look for the very first linker error/warning.

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

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #7

              You can not mix visual studio and mingw libraries. Either compile all with msvc or use QGIS compiled against mingw.

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

              X 3 Replies Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher moved this topic from Qt Creator and other tools on
              • Christian EhrlicherC Christian Ehrlicher

                You can not mix visual studio and mingw libraries. Either compile all with msvc or use QGIS compiled against mingw.

                X Offline
                X Offline
                xanthas
                wrote on last edited by xanthas
                #8
                This post is deleted!
                1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  You can not mix visual studio and mingw libraries. Either compile all with msvc or use QGIS compiled against mingw.

                  X Offline
                  X Offline
                  xanthas
                  wrote on last edited by
                  #9

                  @Christian-Ehrlicher @jsulm

                  @jsulm said in QGiS Windows Source Build:

                  \ in the paths

                  used the abovew as path and still I get

                  @xanthas said in QGiS Windows Source Build:

                  27 different errors like

                  aa25e844-6adc-4b16-a0df-a22f46b79186-image.png

                  jsulmJ 1 Reply Last reply
                  0
                  • X xanthas

                    @Christian-Ehrlicher @jsulm

                    @jsulm said in QGiS Windows Source Build:

                    \ in the paths

                    used the abovew as path and still I get

                    @xanthas said in QGiS Windows Source Build:

                    27 different errors like

                    aa25e844-6adc-4b16-a0df-a22f46b79186-image.png

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

                    @xanthas said in QGiS Windows Source Build:

                    still I get

                    Then please read what @Christian-Ehrlicher wrote.

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

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      You can not mix visual studio and mingw libraries. Either compile all with msvc or use QGIS compiled against mingw.

                      X Offline
                      X Offline
                      xanthas
                      wrote on last edited by
                      #11

                      @Christian-Ehrlicher
                      @jsulm
                      i have tried it and it is giving me 179 errors and I can't find any relative help from other forums as well.
                      aef6ae9e-05b1-4f81-89ad-fcd61bdea41a-image.png

                      Pl45m4P 1 Reply Last reply
                      0
                      • X xanthas

                        @Christian-Ehrlicher
                        @jsulm
                        i have tried it and it is giving me 179 errors and I can't find any relative help from other forums as well.
                        aef6ae9e-05b1-4f81-89ad-fcd61bdea41a-image.png

                        Pl45m4P Offline
                        Pl45m4P Offline
                        Pl45m4
                        wrote on last edited by
                        #12

                        @xanthas said in QGiS Windows Source Build:

                        i have tried it and it is giving me 179 errors

                        What did you "try"?
                        If @Christian-Ehrlicher is correct here with:

                        You can not mix visual studio and mingw libraries. Either compile all with msvc or use QGIS compiled against mingw.

                        trying harder won't solve your problem :)

                        Either switch to MSVC or find another, MinGW supporting, version of QGIS.


                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                        ~E. W. Dijkstra

                        1 Reply Last reply
                        0
                        • X Offline
                          X Offline
                          xanthas
                          wrote on last edited by xanthas
                          #13

                          @Pl45m4
                          So what I have understood is that when I download all dependencies and build QGiS from source, I should either use Qt to compile and build libraries or else I should use visual studio to build and compile it, right?
                          Further, to make the UI and backend codes I should use the same compiler from which I had made the QGiS library, Am I right?

                          What I have understood is the same thing discussed here also, I guess.

                          jsulmJ 1 Reply Last reply
                          0
                          • X xanthas

                            @Pl45m4
                            So what I have understood is that when I download all dependencies and build QGiS from source, I should either use Qt to compile and build libraries or else I should use visual studio to build and compile it, right?
                            Further, to make the UI and backend codes I should use the same compiler from which I had made the QGiS library, Am I right?

                            What I have understood is the same thing discussed here also, I guess.

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

                            @xanthas said in QGiS Windows Source Build:

                            right?

                            No.
                            Qt and visual studio are two completely different things.
                            Qt is a C++ framework, Visual Studio is a IDE.
                            What @Pl45m4 wrote is: you should use MSVC as compiler + Qt built with MSVC.
                            Or you find (or build by yourself) QGIS built with MinGW + Qt built with MinGW.
                            Reason: you cannot mix different C++ compiler (like you do now: MSVC + MinGW).

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

                            1 Reply Last reply
                            4
                            • A Offline
                              A Offline
                              abhishek999
                              wrote on last edited by
                              #15

                              can you give me step by step procedure to integrate qgis project in qt to show map in qt C++
                              i am also facing same issue @jsulm

                              jsulmJ 1 Reply Last reply
                              0
                              • A abhishek999

                                can you give me step by step procedure to integrate qgis project in qt to show map in qt C++
                                i am also facing same issue @jsulm

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

                                @abhishek999 said in QGiS Windows Source Build:

                                can you give me step by step procedure

                                In the first post in this thread there is a link to a step by step explanation, follow it...

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

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  abhishek999
                                  wrote on last edited by
                                  #17

                                  i am facing prolemScreenshot (10).png

                                  here is my .pro file
                                  QT += core gui

                                  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                                  CONFIG += c++17

                                  You can make your code fail to compile if it uses deprecated APIs.

                                  In order to do so, uncomment the following line.

                                  #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

                                  SOURCES +=
                                  main.cpp
                                  mainwindow.cpp

                                  HEADERS +=
                                  mainwindow.h

                                  FORMS +=
                                  mainwindow.ui

                                  Include QGIS headers and libraries manually

                                  INCLUDEPATH += C:\OSGeo4W\apps\qgis-qt6-dev\include

                                  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

                                  INCLUDEPATH += C:/OSGeo4W64/include

                                  Default rules for deployment.

                                  qnx: target.path = /tmp/$${TARGET}/bin
                                  else: unix:!android: target.path = /opt/$${TARGET}/bin
                                  !isEmpty(target.path): INSTALLS += target

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    abhishek999
                                    wrote on last edited by abhishek999
                                    #18

                                    @jsulm @Christian-Ehrlicher
                                    can you please tell me what exact is the problem i have reinstall qt ,Qgis ,OSGeo4W multiples time but still same problem i am facing

                                    1 Reply Last reply
                                    0
                                    • Christian EhrlicherC Online
                                      Christian EhrlicherC Online
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      You still doing the same thing as in your first post - you use a Qt compiled for MinGW and try to link it against a QGis compiled against MSVC. This will not work out - no matter how often you install something...

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

                                      B 1 Reply Last reply
                                      0
                                      • A Offline
                                        A Offline
                                        abhishek999
                                        wrote on last edited by
                                        #20

                                        can you give me the steps to fix this @Christian-Ehrlicher

                                        jsulmJ X 2 Replies Last reply
                                        0
                                        • A abhishek999

                                          can you give me the steps to fix this @Christian-Ehrlicher

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

                                          @abhishek999 Again: you have to use Qt built with MSVC compiler. So, install Qr for MSVC and use it...

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

                                          1 Reply Last reply
                                          1

                                          • Login

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