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. QT Creator: build vs qmake

QT Creator: build vs qmake

Scheduled Pinned Locked Moved Solved General and Desktop
creatorqmakebuild
20 Posts 6 Posters 9.8k 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.
  • Y Offline
    Y Offline
    yur70
    wrote on 15 Apr 2016, 07:14 last edited by
    #1

    I have a problem with building my program using qt creator. I got a .pro file which works with qmake. I.e. I type qmake, then make - everything is compiled.

    Now I open a qt creator project with the same .pro file, try to build it, it says: TCanvas.h: No such file or directory.

    I can also run qmake from qtcreator - it works, but build doesn't work.

    I'm on linux Mint 17.1, Qt Creator 3.0.1, Qt version 4.8.6 for Desktop.

    Here is my .pro file:

    TEMPLATE = app
    
    win32 {
       QMAKE_CXXFLAGS += -FIw32pragma.h  
    }
    CONFIG += qt warn_on thread
    
    INCLUDEPATH += $(ROOTSYS)/include
    win32:LIBS += -L$(ROOTSYS)/lib -llibCore -llibCint -llibRIO -llibNet \
            -llibHist -llibGraf -llibGraf3d -llibGpad -llibTree \
            -llibRint -llibPostscript -llibMatrix -llibPhysics \
            -llibGui -llibRGL 
    else:LIBS += -L$(ROOTSYS)/lib -lCore -lCint -lRIO -lNet \
            -lHist -lGraf -lGraf3d -lGpad -lTree \
            -lRint -lPostscript -lMatrix -lPhysics \
            -lGui -lRGL 
    
    HEADERS += canvas.h
    SOURCES += canvas.cxx main.cxx
    
    
    
    K K 2 Replies Last reply 15 Apr 2016, 07:23
    0
    • Y yur70
      15 Apr 2016, 07:14

      I have a problem with building my program using qt creator. I got a .pro file which works with qmake. I.e. I type qmake, then make - everything is compiled.

      Now I open a qt creator project with the same .pro file, try to build it, it says: TCanvas.h: No such file or directory.

      I can also run qmake from qtcreator - it works, but build doesn't work.

      I'm on linux Mint 17.1, Qt Creator 3.0.1, Qt version 4.8.6 for Desktop.

      Here is my .pro file:

      TEMPLATE = app
      
      win32 {
         QMAKE_CXXFLAGS += -FIw32pragma.h  
      }
      CONFIG += qt warn_on thread
      
      INCLUDEPATH += $(ROOTSYS)/include
      win32:LIBS += -L$(ROOTSYS)/lib -llibCore -llibCint -llibRIO -llibNet \
              -llibHist -llibGraf -llibGraf3d -llibGpad -llibTree \
              -llibRint -llibPostscript -llibMatrix -llibPhysics \
              -llibGui -llibRGL 
      else:LIBS += -L$(ROOTSYS)/lib -lCore -lCint -lRIO -lNet \
              -lHist -lGraf -lGraf3d -lGpad -lTree \
              -lRint -lPostscript -lMatrix -lPhysics \
              -lGui -lRGL 
      
      HEADERS += canvas.h
      SOURCES += canvas.cxx main.cxx
      
      
      
      K Offline
      K Offline
      KiwiJeff
      wrote on 15 Apr 2016, 07:23 last edited by
      #2

      My first suggestion would be to look at the compile output and see which paths are used to look for TCanvas.h.

      Y 1 Reply Last reply 15 Apr 2016, 07:47
      0
      • Y yur70
        15 Apr 2016, 07:14

        I have a problem with building my program using qt creator. I got a .pro file which works with qmake. I.e. I type qmake, then make - everything is compiled.

        Now I open a qt creator project with the same .pro file, try to build it, it says: TCanvas.h: No such file or directory.

        I can also run qmake from qtcreator - it works, but build doesn't work.

        I'm on linux Mint 17.1, Qt Creator 3.0.1, Qt version 4.8.6 for Desktop.

        Here is my .pro file:

        TEMPLATE = app
        
        win32 {
           QMAKE_CXXFLAGS += -FIw32pragma.h  
        }
        CONFIG += qt warn_on thread
        
        INCLUDEPATH += $(ROOTSYS)/include
        win32:LIBS += -L$(ROOTSYS)/lib -llibCore -llibCint -llibRIO -llibNet \
                -llibHist -llibGraf -llibGraf3d -llibGpad -llibTree \
                -llibRint -llibPostscript -llibMatrix -llibPhysics \
                -llibGui -llibRGL 
        else:LIBS += -L$(ROOTSYS)/lib -lCore -lCint -lRIO -lNet \
                -lHist -lGraf -lGraf3d -lGpad -lTree \
                -lRint -lPostscript -lMatrix -lPhysics \
                -lGui -lRGL 
        
        HEADERS += canvas.h
        SOURCES += canvas.cxx main.cxx
        
        
        
        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 15 Apr 2016, 07:36 last edited by
        #3

        @yur70
        Is the qmake that QtCreator uses the same as the one you use from the command line? Have you installed all the needed -dev packages (if any)?

        -L$(ROOTSYS)/lib
        

        What is ROOTSYS and why do you need to use it, is it set correctly?

        Read and abide by the Qt Code of Conduct

        J Y 2 Replies Last reply 15 Apr 2016, 07:44
        0
        • K kshegunov
          15 Apr 2016, 07:36

          @yur70
          Is the qmake that QtCreator uses the same as the one you use from the command line? Have you installed all the needed -dev packages (if any)?

          -L$(ROOTSYS)/lib
          

          What is ROOTSYS and why do you need to use it, is it set correctly?

          J Offline
          J Offline
          JohanSolo
          wrote on 15 Apr 2016, 07:44 last edited by JohanSolo
          #4

          @kshegunov said:

          What is ROOTSYS and why do you need to use it, is it set correctly?

          ROOT is a very powerfull statistical data analysis framework, initially developped for Particle Physics (ROOT website). The traditional way to use ROOT once compiled is to define the ROOTSYS environment variable and not add the binaries in the path (why, I don't know...).

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          K 1 Reply Last reply 15 Apr 2016, 08:05
          0
          • K KiwiJeff
            15 Apr 2016, 07:23

            My first suggestion would be to look at the compile output and see which paths are used to look for TCanvas.h.

            Y Offline
            Y Offline
            yur70
            wrote on 15 Apr 2016, 07:47 last edited by
            #5

            @KiwiJeff The point is: all paths are correct, it all works with qmake. Why doesn't it work with "build"?

            K 1 Reply Last reply 15 Apr 2016, 08:19
            0
            • J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 15 Apr 2016, 07:51 last edited by jsulm
              #6

              As @kshegunov already asked: are you sure you're using the same qmake in QtCreator?
              Where and how do you set ROOTSYS environment variable?
              You can set this variable in QtCreator in project settings under "Build Environment".
              And in the compiler output you can check whether al paths are really passed to the compiler.

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

              Y 1 Reply Last reply 15 Apr 2016, 07:59
              0
              • K kshegunov
                15 Apr 2016, 07:36

                @yur70
                Is the qmake that QtCreator uses the same as the one you use from the command line? Have you installed all the needed -dev packages (if any)?

                -L$(ROOTSYS)/lib
                

                What is ROOTSYS and why do you need to use it, is it set correctly?

                Y Offline
                Y Offline
                yur70
                wrote on 15 Apr 2016, 07:52 last edited by
                #7

                @kshegunov said:

                @yur70
                Is the qmake that QtCreator uses the same as the one you use from the command line? Have you installed all the needed -dev packages (if any)?

                -L$(ROOTSYS)/lib
                

                What is ROOTSYS and why do you need to use it, is it set correctly?

                I believe that qmake is always the same. I can go to the build-Desktop-Debug folder (which is created by the qtcreator) and run qmake + make from there, it all works. But the "build" command from qtcreator doesn't.

                ROOTSYS is sen correctly. I can replace it by the full path to the libraries (/cern/root), but the result is the same.

                1 Reply Last reply
                0
                • Y Offline
                  Y Offline
                  yeckel
                  wrote on 15 Apr 2016, 07:55 last edited by
                  #8

                  QtCreator is by default creating new directory for builds, if you forgot this file, it can create the problem. Try building in QtCreator in the same directory where sources are. Go in Projects->Build->de-select "Shadow Build"

                  J 1 Reply Last reply 15 Apr 2016, 07:59
                  0
                  • Y yeckel
                    15 Apr 2016, 07:55

                    QtCreator is by default creating new directory for builds, if you forgot this file, it can create the problem. Try building in QtCreator in the same directory where sources are. Go in Projects->Build->de-select "Shadow Build"

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 15 Apr 2016, 07:59 last edited by
                    #9

                    @yeckel I don't think this will help as the missing header file is not part of the project but of an external library.
                    I think the problem is that ROOTSYS is not set in QtCreator: INCLUDEPATH += $(ROOTSYS)/include

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

                    1 Reply Last reply
                    1
                    • J jsulm
                      15 Apr 2016, 07:51

                      As @kshegunov already asked: are you sure you're using the same qmake in QtCreator?
                      Where and how do you set ROOTSYS environment variable?
                      You can set this variable in QtCreator in project settings under "Build Environment".
                      And in the compiler output you can check whether al paths are really passed to the compiler.

                      Y Offline
                      Y Offline
                      yur70
                      wrote on 15 Apr 2016, 07:59 last edited by
                      #10

                      @jsulm said:

                      As @kshegunov already asked: are you sure you're using the same qmake in QtCreator?
                      Where and how do you set ROOTSYS environment variable?
                      You can set this variable in QtCreator in project settings under "Build Environment".
                      And in the compiler output you can check whether al paths are really passed to the compiler.

                      It doesn't matter if qmake is the same or not. With qmake it always works: I can run qmake from the command line, and also use "Run qmake" from qtcreator (by right clicking on the project). So qmake (or "Run qmake") - works, build - doesn't work.

                      J 1 Reply Last reply 15 Apr 2016, 08:02
                      0
                      • Y yur70
                        15 Apr 2016, 07:59

                        @jsulm said:

                        As @kshegunov already asked: are you sure you're using the same qmake in QtCreator?
                        Where and how do you set ROOTSYS environment variable?
                        You can set this variable in QtCreator in project settings under "Build Environment".
                        And in the compiler output you can check whether al paths are really passed to the compiler.

                        It doesn't matter if qmake is the same or not. With qmake it always works: I can run qmake from the command line, and also use "Run qmake" from qtcreator (by right clicking on the project). So qmake (or "Run qmake") - works, build - doesn't work.

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 15 Apr 2016, 08:02 last edited by
                        #11

                        @yur70 What about my other question regarding ROOTSYS?
                        I think, in QtCreator Projects/Build Environment it is not set, so this

                        INCLUDEPATH += $(ROOTSYS)/include
                        

                        expands to /include, so TCanvas.h is not found (I assume it is part of ROOT, right?).
                        You can easily check that looking at the compiler output (you can see there which pats are passed to the compiler, look for -I...).

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

                        K 1 Reply Last reply 15 Apr 2016, 08:23
                        0
                        • J JohanSolo
                          15 Apr 2016, 07:44

                          @kshegunov said:

                          What is ROOTSYS and why do you need to use it, is it set correctly?

                          ROOT is a very powerfull statistical data analysis framework, initially developped for Particle Physics (ROOT website). The traditional way to use ROOT once compiled is to define the ROOTSYS environment variable and not add the binaries in the path (why, I don't know...).

                          K Offline
                          K Offline
                          kshegunov
                          Moderators
                          wrote on 15 Apr 2016, 08:05 last edited by
                          #12

                          @JohanSolo
                          Being a nuclear physicist myself I know what ROOT is, what I didn't know is how it's set up, as I haven't used it. Since ROOTSYS is simply a variable I didn't deduce that it's one defined for/used by CERN's ROOT. Thanks for the explanation though!

                          @yur70

                          With qmake it always works: I can run qmake from the command line, and also use "Run qmake" from qtcreator (by right clicking on the project). So qmake (or "Run qmake") - works, build - doesn't work.

                          qmake is an intermediate step before building. It takes a .pro (project) file and generates an ordinary Makefile from that. What it doesn't do is check the flags you pass to the compiler/linker or paths. That's why the question "Are all paths correct during the build step?" is relevant. So, could you please post the whole build line with all the compiler switches, and not only the error you get?

                          Read and abide by the Qt Code of Conduct

                          1 Reply Last reply
                          0
                          • Y yur70
                            15 Apr 2016, 07:47

                            @KiwiJeff The point is: all paths are correct, it all works with qmake. Why doesn't it work with "build"?

                            K Offline
                            K Offline
                            KiwiJeff
                            wrote on 15 Apr 2016, 08:19 last edited by
                            #13

                            @yur70 Because qmake only does a syntax check and generates a Makefile and Moc files (and probably some other tasks unrelated to your paths). It is the build steps that requires the include paths to be correct. That is why I suggested looking at the compile output and verifying the paths there.

                            1 Reply Last reply
                            0
                            • J jsulm
                              15 Apr 2016, 08:02

                              @yur70 What about my other question regarding ROOTSYS?
                              I think, in QtCreator Projects/Build Environment it is not set, so this

                              INCLUDEPATH += $(ROOTSYS)/include
                              

                              expands to /include, so TCanvas.h is not found (I assume it is part of ROOT, right?).
                              You can easily check that looking at the compiler output (you can see there which pats are passed to the compiler, look for -I...).

                              K Offline
                              K Offline
                              kshegunov
                              Moderators
                              wrote on 15 Apr 2016, 08:23 last edited by kshegunov
                              #14

                              @jsulm

                              I think, in QtCreator Projects/Build Environment it is not set, so this
                              INCLUDEPATH += $(ROOTSYS)/include
                              expands to /include

                              The expansion happens in the Makefile's processing, if such is required when qmake is run the double dollar variable reference is required, i.e.: INCLUDEPATH += $$(ROOTSYS)/include

                              (Posting this only for completeness)

                              Read and abide by the Qt Code of Conduct

                              J 1 Reply Last reply 15 Apr 2016, 08:26
                              0
                              • K kshegunov
                                15 Apr 2016, 08:23

                                @jsulm

                                I think, in QtCreator Projects/Build Environment it is not set, so this
                                INCLUDEPATH += $(ROOTSYS)/include
                                expands to /include

                                The expansion happens in the Makefile's processing, if such is required when qmake is run the double dollar variable reference is required, i.e.: INCLUDEPATH += $$(ROOTSYS)/include

                                (Posting this only for completeness)

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 15 Apr 2016, 08:26 last edited by
                                #15

                                @kshegunov Wherever the expansion happens if ROOTSYS is not set the resulting path will be invalid.
                                We really need the complete build log to check this.

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

                                K 1 Reply Last reply 15 Apr 2016, 08:36
                                0
                                • J jsulm
                                  15 Apr 2016, 08:26

                                  @kshegunov Wherever the expansion happens if ROOTSYS is not set the resulting path will be invalid.
                                  We really need the complete build log to check this.

                                  K Offline
                                  K Offline
                                  kshegunov
                                  Moderators
                                  wrote on 15 Apr 2016, 08:36 last edited by
                                  #16

                                  @jsulm said:

                                  Wherever the expansion happens if ROOTSYS is not set the resulting path will be invalid.
                                  We really need the complete build log to check this.

                                  I certainly don't argue against that! :)

                                  Read and abide by the Qt Code of Conduct

                                  1 Reply Last reply
                                  0
                                  • Y Offline
                                    Y Offline
                                    yur70
                                    wrote on 15 Apr 2016, 09:19 last edited by
                                    #17

                                    Thanks for your help, guys. The problem seems to be indeed in the environment variable. I set ROOTSYS in the Projects/Build Environment, now it finds the headers, but I get the following error:

                                    :-1: warning: libMathCore.so, needed by /cern/root/lib/libHist.so, not found (try using -rpath or -rpath-link)
                                    

                                    .. and then a lot of errors with undefined reference.

                                    Where and how should I insert "-rpath"?

                                    K J 2 Replies Last reply 15 Apr 2016, 09:24
                                    0
                                    • Y yur70
                                      15 Apr 2016, 09:19

                                      Thanks for your help, guys. The problem seems to be indeed in the environment variable. I set ROOTSYS in the Projects/Build Environment, now it finds the headers, but I get the following error:

                                      :-1: warning: libMathCore.so, needed by /cern/root/lib/libHist.so, not found (try using -rpath or -rpath-link)
                                      

                                      .. and then a lot of errors with undefined reference.

                                      Where and how should I insert "-rpath"?

                                      K Offline
                                      K Offline
                                      kshegunov
                                      Moderators
                                      wrote on 15 Apr 2016, 09:24 last edited by kshegunov
                                      #18

                                      @yur70

                                      Where and how should I insert "-rpath"?

                                      For development you shouldn't. Make sure you have the required binary in the linker search path. You need to have libMathCore.so in the $(ROOTSYS)/lib directory. If you need to add additional path for the linker add another -L switch to the LIBS variable in your project file:

                                      LIBS += -L/another/path/to/search/for/so/files
                                      

                                      If you're not building the libHist.so yourself, then provide additional linker paths by appending LD_LIBRARY_PATH (again, this is for development).

                                      Read and abide by the Qt Code of Conduct

                                      1 Reply Last reply
                                      0
                                      • Y yur70
                                        15 Apr 2016, 09:19

                                        Thanks for your help, guys. The problem seems to be indeed in the environment variable. I set ROOTSYS in the Projects/Build Environment, now it finds the headers, but I get the following error:

                                        :-1: warning: libMathCore.so, needed by /cern/root/lib/libHist.so, not found (try using -rpath or -rpath-link)
                                        

                                        .. and then a lot of errors with undefined reference.

                                        Where and how should I insert "-rpath"?

                                        J Offline
                                        J Offline
                                        JohanSolo
                                        wrote on 15 Apr 2016, 09:41 last edited by JohanSolo
                                        #19

                                        @yur70 said:

                                        :-1: warning: libMathCore.so, needed by /cern/root/lib/libHist.so, not found (try using -rpath or -rpath-link)
                                        

                                        The libMathCore.so should be in your /cern/root/lib/ directory as well (it's a ROOT lib as well). You should check your ROOT installation. I guess you compiled it yourself (otherwise no need for ROOTSYS to be defined).

                                        `They did not know it was impossible, so they did it.'
                                        -- Mark Twain

                                        1 Reply Last reply
                                        0
                                        • Y Offline
                                          Y Offline
                                          yur70
                                          wrote on 15 Apr 2016, 09:59 last edited by
                                          #20

                                          Finally, I found the reason. I had to add -Wl,-rpath,$(ROOTSYS)/lib to the end of the LIBS definition. So the solution is the following:

                                          1. Add ROOTSYS to the Projects/Build Environment
                                          2. Add -Wl,-rpath,$(ROOTSYS)/lib to the libs.

                                          The .pro file looks like this:

                                          TEMPLATE = app
                                          
                                          win32 {
                                             QMAKE_CXXFLAGS += -FIw32pragma.h  
                                          }
                                          CONFIG += qt warn_on thread
                                          
                                          INCLUDEPATH += $(ROOTSYS)/include
                                          win32:LIBS += -L$(ROOTSYS)/lib -llibCore -llibCint -llibRIO -llibNet \
                                                  -llibHist -llibGraf -llibGraf3d -llibGpad -llibTree \
                                                  -llibRint -llibPostscript -llibMatrix -llibPhysics \
                                                  -llibGui -llibRGL 
                                          else:LIBS += -L$(ROOTSYS)/lib -lCore -lCint -lRIO -lNet \
                                                  -lHist -lGraf -lGraf3d -lGpad -lTree \
                                                  -lRint -lPostscript -lMatrix -lPhysics \
                                                  -lGui -lRGL -Wl,-rpath,$(ROOTSYS)/lib
                                          
                                          HEADERS += canvas.h
                                          SOURCES += canvas.cxx main.cxx
                                          
                                          
                                          1 Reply Last reply
                                          0

                                          8/20

                                          15 Apr 2016, 07:55

                                          • Login

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