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
Forum Updated to NodeBB v4.3 + New Features

QT Creator: build vs qmake

Scheduled Pinned Locked Moved Solved General and Desktop
creatorqmakebuild
20 Posts 6 Posters 9.9k Views 4 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.
  • yur70Y yur70

    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
    
    
    
    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on 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

    JohanSoloJ yur70Y 2 Replies Last reply
    0
    • kshegunovK kshegunov

      @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?

      JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on 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

      kshegunovK 1 Reply Last reply
      0
      • KiwiJeffK KiwiJeff

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

        yur70Y Offline
        yur70Y Offline
        yur70
        wrote on last edited by
        #5

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

        KiwiJeffK 1 Reply Last reply
        0
        • jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on 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

          yur70Y 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @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?

            yur70Y Offline
            yur70Y Offline
            yur70
            wrote on 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
            • yeckelY Offline
              yeckelY Offline
              yeckel
              wrote on 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"

              jsulmJ 1 Reply Last reply
              0
              • yeckelY yeckel

                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"

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on 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
                • jsulmJ jsulm

                  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.

                  yur70Y Offline
                  yur70Y Offline
                  yur70
                  wrote on 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.

                  jsulmJ 1 Reply Last reply
                  0
                  • yur70Y yur70

                    @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.

                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on 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

                    kshegunovK 1 Reply Last reply
                    0
                    • JohanSoloJ JohanSolo

                      @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...).

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on 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
                      • yur70Y yur70

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

                        KiwiJeffK Offline
                        KiwiJeffK Offline
                        KiwiJeff
                        wrote on 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
                        • jsulmJ jsulm

                          @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...).

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on 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

                          jsulmJ 1 Reply Last reply
                          0
                          • kshegunovK kshegunov

                            @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)

                            jsulmJ Online
                            jsulmJ Online
                            jsulm
                            Lifetime Qt Champion
                            wrote on 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

                            kshegunovK 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @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.

                              kshegunovK Offline
                              kshegunovK Offline
                              kshegunov
                              Moderators
                              wrote on 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
                              • yur70Y Offline
                                yur70Y Offline
                                yur70
                                wrote on 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"?

                                kshegunovK JohanSoloJ 2 Replies Last reply
                                0
                                • yur70Y yur70

                                  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"?

                                  kshegunovK Offline
                                  kshegunovK Offline
                                  kshegunov
                                  Moderators
                                  wrote on 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
                                  • yur70Y yur70

                                    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"?

                                    JohanSoloJ Offline
                                    JohanSoloJ Offline
                                    JohanSolo
                                    wrote on 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
                                    • yur70Y Offline
                                      yur70Y Offline
                                      yur70
                                      wrote on 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

                                      • Login

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