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. The dark side of .pro file
Forum Updated to NodeBB v4.3 + New Features

The dark side of .pro file

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 5 Posters 1.9k Views 3 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.
  • M Offline
    M Offline
    MMonty1960
    wrote on last edited by
    #1

    Re: Plotting 3D surface

    Sorry, certainly I am just a normal user, but it is the second time that initially obscure errors for the proper program compiling can be solved adding a quite magical (for me) line to the .pro file.
    The first time, creating a widget in Qt5, even if the command "qmake -project" was launched, the .pro file was missing for the line QT+=widget
    Now, trying to compile the "Surface Example" I spent a lot of time to find the problem of the broken compilation with the message /home/marco/Workspace/QtSource/feritoMetro/fermet.cpp:236: error: undefined reference to `QtDataVisualization::Q3DSurface::Q3DSurface(QSurfaceFormat const*, QWindow*)’
    The solution is add QT*=datavisualization to the .pro file.
    My question is, why those lines are not automatically added or al least suggested by qmake -project?

    JKSHJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Because qmake does not do deep inspections of all the files of your project.

      This would require processing each and every include which is not its job. You can add on the command line additional informations when running qmake -project.

      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
      4
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Well those are all modules and its not for sure you would need them at all
        so qmake -project could not either add all of them or none.
        https://doc.qt.io/qt-5/qtmodules.html

        However, if you create the project via Creator, then the Widgets module is added if you select Default GUI project.

        Also, the docs tells what module to add for a given class
        alt text

        M 1 Reply Last reply
        3
        • mrjjM mrjj

          Hi
          Well those are all modules and its not for sure you would need them at all
          so qmake -project could not either add all of them or none.
          https://doc.qt.io/qt-5/qtmodules.html

          However, if you create the project via Creator, then the Widgets module is added if you select Default GUI project.

          Also, the docs tells what module to add for a given class
          alt text

          M Offline
          M Offline
          MMonty1960
          wrote on last edited by
          #4

          @mrjj many thanks for your answer. You are right, one should always carefully read the whole documentation. Unfortunately very often one is searching for quick solutions to specific needs and jump directly to the example.
          In any case I found the same issue by trying the compile the "Surface Example" among the ones offered in example section of QtCreator. At least in that case I expect that the .pro file was rightly composed; instead after some hours I gave up.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by SGaist
            #5

            One thing that is strange is why are you calling qmake -project when trying to build one of the examples since they already have .pro files ?

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

            M 1 Reply Last reply
            1
            • M MMonty1960

              Re: Plotting 3D surface

              Sorry, certainly I am just a normal user, but it is the second time that initially obscure errors for the proper program compiling can be solved adding a quite magical (for me) line to the .pro file.
              The first time, creating a widget in Qt5, even if the command "qmake -project" was launched, the .pro file was missing for the line QT+=widget
              Now, trying to compile the "Surface Example" I spent a lot of time to find the problem of the broken compilation with the message /home/marco/Workspace/QtSource/feritoMetro/fermet.cpp:236: error: undefined reference to `QtDataVisualization::Q3DSurface::Q3DSurface(QSurfaceFormat const*, QWindow*)’
              The solution is add QT*=datavisualization to the .pro file.
              My question is, why those lines are not automatically added or al least suggested by qmake -project?

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              Hi, and welcome!

              @MMonty1960 said in The dark side of .pro file:

              My question is, why those lines are not automatically added or al least suggested by qmake -project?

              This is documented at https://doc.qt.io/qt-5/qmake-running.html : "Note: It is likely that the created file will need to be edited. For example, adding the QT variable to suit what modules are required for the project."

              qmake -project simply adds your existing .h and .cpp files to a .pro file. It doesn't know which modules your project needs.

              On a related note, you probably never need to call qmake -project. Ever.

              In any case I found the same issue by trying the compile the "Surface Example" among the ones offered in example section of QtCreator. At least in that case I expect that the .pro file was rightly composed

              Do you mean https://doc.qt.io/qt-5/qtdatavisualization-surface-example.html ? The example already comes with a surface.pro file which was set up correctly; just use that.

              However, if you ran qmake -project in the example folder, that means you erased the existing (correct) .pro file and replaced it with an incomplete one. You'll need to reinstall the Qt Data Visualization module to restore the surface.pro file.

              initially obscure errors for the proper program compiling can be solved adding a quite magical (for me) line to the .pro file.

              No magic is involved; everything is perfectly logical and documented.

              "undefined reference" means that your linker can't find a library (this is applies to all C++ projects, not just Qt). So, you need to make sure your tools can find the libraries. With .pro files, this involves telling qmake which modules you need:

              • QT += widgets means "add the Qt Widgets module to the list of modules needed by our project".
              • QT += datavisualization means "add the Qt Data Visualization module to the list of modules needed by our project".

              See a pattern?

              Finally, see https://doc.qt.io/qt-5/qmake-language.html for the difference between += and *=

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2
              • SGaistS SGaist

                One thing that is strange is why are you calling qmake -project when trying to build one of the examples since they already have .pro files ?

                M Offline
                M Offline
                MMonty1960
                wrote on last edited by
                #7

                @SGaist It was just one of N trials I did to solve the problem

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Can you provide a link to that example ?

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

                  JKSHJ 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Can you provide a link to that example ?

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #9

                    @SGaist said in The dark side of .pro file:

                    Can you provide a link to that example ?

                    I believe it's https://doc.qt.io/qt-5/qtdatavisualization-surface-example.html. I just tested it with Qt 5.15.2 and the *.pro file works fine.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    SGaistS M 2 Replies Last reply
                    0
                    • JKSHJ JKSH

                      @SGaist said in The dark side of .pro file:

                      Can you provide a link to that example ?

                      I believe it's https://doc.qt.io/qt-5/qtdatavisualization-surface-example.html. I just tested it with Qt 5.15.2 and the *.pro file works fine.

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @JKSH I believe too. The thing with it is that it uses "../examples.pri" which is where the common "QT" configuration is done. So there might be something there with the building issue.

                      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
                      1
                      • JKSHJ JKSH

                        @SGaist said in The dark side of .pro file:

                        Can you provide a link to that example ?

                        I believe it's https://doc.qt.io/qt-5/qtdatavisualization-surface-example.html. I just tested it with Qt 5.15.2 and the *.pro file works fine.

                        M Offline
                        M Offline
                        MMonty1960
                        wrote on last edited by
                        #11

                        @JKSH I am using Manjaro linux 64 bit xfce. When I select the "Surface example" a window pops-up asking is I want "copy and open" or "keep project and open". If I select "keep project and open", as next step I have to push "configure project" (I select Qt 5.10.1). Then the generated pro file is:
                        android|ios|winrt {
                        error( "This example is not supported for android, ios, or winrt." )
                        }

                        !include( ../examples.pri ) {
                        error( "Couldn't find the examples.pri file!" )
                        }

                        SOURCES += main.cpp
                        surfacegraph.cpp

                        HEADERS += surfacegraph.h

                        QT += widgets
                        requires(qtConfig(combobox))

                        RESOURCES += surface.qrc

                        OTHER_FILES += doc/src/*
                        doc/images/*

                        Of course that is the end of the experience. The same happen in the other choice. Maybe there is some error in my linux distro.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          So my idea was correct, you are missing the examples.pri file.

                          Don't you have the warning shown when building the project ?

                          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
                          • M Offline
                            M Offline
                            MMonty1960
                            wrote on last edited by
                            #13

                            I find the issue "/example.pri" only in the choice "copy and open". I solved by manually copying that file, but the pro file remained unchanged and one again the experience end

                            JKSHJ 1 Reply Last reply
                            0
                            • M MMonty1960

                              I find the issue "/example.pri" only in the choice "copy and open". I solved by manually copying that file, but the pro file remained unchanged and one again the experience end

                              JKSHJ Offline
                              JKSHJ Offline
                              JKSH
                              Moderators
                              wrote on last edited by
                              #14

                              @MMonty1960 said in The dark side of .pro file:

                              but the pro file remained unchanged and one again the experience end

                              The pro file should remain unchanged since it is correct.

                              What do you mean "the experience end"? What happens when you use Qt Creator to build and run the project?

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              M 1 Reply Last reply
                              0
                              • JKSHJ JKSH

                                @MMonty1960 said in The dark side of .pro file:

                                but the pro file remained unchanged and one again the experience end

                                The pro file should remain unchanged since it is correct.

                                What do you mean "the experience end"? What happens when you use Qt Creator to build and run the project?

                                M Offline
                                M Offline
                                MMonty1960
                                wrote on last edited by
                                #15

                                @JKSH The pro file is not correct because is missing for QT+=datavisualization so compilation fails.
                                Now I know the solution, thus if I add manually that line the compilation runs correctly.
                                In any case I would like to thank both SGaist and JKSH because I learned a lot by your answers. Many thanks!!!!

                                JKSHJ 1 Reply Last reply
                                0
                                • Christian EhrlicherC Offline
                                  Christian EhrlicherC Offline
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @MMonty1960 said in The dark side of .pro file:

                                  The pro file is not correct because is missing for QT+=datavisualization so compilation fails.

                                  As @SGaist already told you examples.pri contains more stuff. When you take a look into it you will notice a 'QT += datavisualization' line so the pro file is correct.

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

                                  1 Reply Last reply
                                  1
                                  • M MMonty1960

                                    @JKSH The pro file is not correct because is missing for QT+=datavisualization so compilation fails.
                                    Now I know the solution, thus if I add manually that line the compilation runs correctly.
                                    In any case I would like to thank both SGaist and JKSH because I learned a lot by your answers. Many thanks!!!!

                                    JKSHJ Offline
                                    JKSHJ Offline
                                    JKSH
                                    Moderators
                                    wrote on last edited by
                                    #17

                                    @MMonty1960 said in The dark side of .pro file:

                                    @JKSH The pro file is not correct because is missing for QT+=datavisualization so compilation fails.

                                    The pro file is correct. You just need to make sure that examples.pri is in the folder above surfaces.pro so that QT += datavisualization is included via include(../examples.pri). You don't need to modify surfaces.pro.

                                    But anyway, you have highlighted a weakness in the way examples are loaded so I opened a bug report: https://bugreports.qt.io/browse/QTCREATORBUG-25191

                                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                    M 1 Reply Last reply
                                    1
                                    • JKSHJ JKSH

                                      @MMonty1960 said in The dark side of .pro file:

                                      @JKSH The pro file is not correct because is missing for QT+=datavisualization so compilation fails.

                                      The pro file is correct. You just need to make sure that examples.pri is in the folder above surfaces.pro so that QT += datavisualization is included via include(../examples.pri). You don't need to modify surfaces.pro.

                                      But anyway, you have highlighted a weakness in the way examples are loaded so I opened a bug report: https://bugreports.qt.io/browse/QTCREATORBUG-25191

                                      M Offline
                                      M Offline
                                      MMonty1960
                                      wrote on last edited by
                                      #18

                                      @JKSH Of course I copied example.pri in the folder above surface.pro, but there is no effect on the pro file and compilation crashed. Maybe the reason is that the pro file is composed before I applied the correction and after that is not more refreshed. In any case I failed to compile and run the example.

                                      JKSHJ 1 Reply Last reply
                                      0
                                      • M MMonty1960

                                        @JKSH Of course I copied example.pri in the folder above surface.pro, but there is no effect on the pro file and compilation crashed. Maybe the reason is that the pro file is composed before I applied the correction and after that is not more refreshed. In any case I failed to compile and run the example.

                                        JKSHJ Offline
                                        JKSHJ Offline
                                        JKSH
                                        Moderators
                                        wrote on last edited by
                                        #19

                                        @MMonty1960 said in The dark side of .pro file:

                                        Maybe the reason is that the pro file is composed before I applied the correction and after that is not more refreshed.

                                        Yes, you're right. You can force a refresh by clicking Build > Run qmake. That should let you compile and run the example.

                                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                        1 Reply Last reply
                                        2

                                        • Login

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