Results 1 to 18 of 18

Thread: qmake behavior

  1. #1
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qmake behavior

    For some unknown reason, my qmake seems to ignore changes in header files and in .ui files. Only newer "source code" files are processed. When I make a change in a *.hpp or in a *.ui, the project isn't recompiled properly. I need to rebuild the whole project whenever I update a *.hpp or .ui .

    As long as the project is small, it is a nuisance but so be it. As the project grows, the need for rebuilding becomes less and less bearable. At present, I have about 80 files and I am calling help: Every time I make a change in a single .hpp which affects only a few files in the project, I have to recompile everything. I know that the project will be bigger and that I will continue tuning my headers...

    I am using standard tools: Qt Creator and Qt Designer. Debian Wheezy KDE, 64-bit, Qt 4.8.2 . What should I set to persuade "build" of the Creator to take changed headers into consideration?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    Can you show us your .pro file?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    viewer-qt.pro

    Qt Code:
    1. TEMPLATE = app
    2. TARGET = viewer-qt
    3. FORMS = viewer.ui \
    4. opendlg.ui
    5. QT = core gui
    6. QMAKE_CXXFLAGS += -std=c++11
    7. INCLUDEPATH += hpp
    8. RESOURCES = viewer.qrc
    9. LIBS += /usr/lib/libkdeui.so
    10.  
    11. HEADERS += \
    12. hpp/myframe.hpp \
    13. hpp/myapp.hpp \
    14. hpp/tree.hpp \
    15. hpp/treeitem.hpp \
    16. hpp/text.hpp \
    17. hpp/appconf.hpp \
    18. hpp/treetraverser.hpp \
    19. hpp/dirtraverser.hpp \
    20. hpp/opendlgitem.hpp \
    21. hpp/opendlg.hpp \
    22. hpp/textparser.hpp
    23.  
    24. SOURCES += \
    25. main/main.cpp \
    26. myapp/myapp-ctor1.cpp \
    27. myapp/myapp-dtor.cpp \
    28. myframe/myframe-ctor1.cpp \
    29. myframe/myframe-dtor.cpp \
    30.  
    31. <other .cpp files follow>
    32. <end of profile, no other commands follow>
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    The project file looks ok, provided that in your source files refer to the header files using appropriate paths. GCC should be able to detect dependencies then and the project should be rebuilt automatically. If this does not happen, then most probably your include statements are not correct. Somehow gcc cannot generate proper dependency information.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    The #includes, placements and compiler settings should be ok, Wysota. Otherwise, rebuild would not build correctly. The problem seems to consist in the KDE build of Qt somehow. I do not believe that Qt itself is buggy - there are too many Qt users around.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    Rebuild is one thing, dependency generation is another. The issue you have is not related to Qt but rather more to "gcc -E" and is likely caused by your project configuration (and by that I mean not only the project file but also your actual source code).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    The code is a completely standard one, all headers are included using #include. The project configuration is default. I haven't meddled with this at all. I have written a core or the .pro file (lines 1 .. 9) and let the Creator to do the rest.

    The only possible suspect can be #pragma once instead of #ifndef #define #endif (I prefer #pragma once from #ifndef etc.). I am sure that g++ processes #pragma once correctly. Does Qt Creator dependency building process #pragma once correctly?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    Quote Originally Posted by Radek View Post
    The code is a completely standard one, all headers are included using #include.
    It is not as your source files reside in different directories. I would consider a "standard" code layout such, that is all within a single directory.

    Does Qt Creator dependency building process #pragma once correctly?
    Qt Creator does not do any dependency building. QMake does through your compiler (e.g. gcc -M). From what I see there is a number of threads in the Internet about issues with dependency generation for files scattered across different directories. As a simple experiment I'd suggest to move all your source files to one directory, all your header files to a second directory and see if the problem persists.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    IMO, it's not a GCC problem. In my Gnome times, I developed with Code Blocks and wxWidgets and I never met a problem like this. But then Gnome 3 arrived and I run away from Gnome as fast as I could. KDE is okay for me but I have lost both wxWidgets and Code Blocks. Therefore, Qt.

    I will return to rebuilding. A single directory is unmanageable for me even if it solved my problem.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    Quote Originally Posted by Radek View Post
    IMO, it's not a GCC problem. In my Gnome times, I developed with Code Blocks and wxWidgets and I never met a problem like this.
    I don't have such problems with Qt as well however since the only two tools involved in building your project are make and the compiler, somehow it doesn't suprise me. "Qt" (read qmake) is not part of the build chain here.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qmake behavior

    This is an experiment, not a description of a solution I know works...
    Try adding
    Qt Code:
    1. DEPENDPATH += hpp
    To copy to clipboard, switch view to plain text mode 
    To the pro fle and rerun qmake. Inspect the Makefile to see what each cpp file is dependent on efore and after doing this.

  12. The following user says thank you to ChrisW67 for this useful post:

    Radek (20th August 2013)

  13. #12
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    Thanks ChrisW67! This seems to work! I added "int trythis;" into a header, recompiled (not so long recompiling, not everything got rebuilt evidently), run debug and inspected the class. It contained "trythis" as it should do. My makefile now contains references to header files. It did not before.

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    Out of curiosity (I didn't get a response last time I indirectly asked about it) -- how exactly do you include statements look like? Do they use relative paths? I mean do they look like:

    Qt Code:
    1. #include "../hpp/myframe.hpp"
    To copy to clipboard, switch view to plain text mode 

    or rather

    Qt Code:
    1. #include "myframe.hpp" // or <myframe.hpp>
    To copy to clipboard, switch view to plain text mode 

    ?

    If DEPENDPATH helps then it is likely you are using the latter.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #14
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    #include <myframe.hpp> with all my headers. That's why I have set INCLUDEPATH.

  16. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    For that you need DEPENDPATH as well

    See the docs (underlined by me):

    Quote Originally Posted by DEPENDPATH

    This variable contains the list of all directories to look in to resolve dependencies. This will be used when crawling through included files.
    INCLUDEPATH is only used for compilation (e.g. it makes no sense to make your app dependent of /usr/include/*, right?).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #16
    Join Date
    Nov 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    I don't wish to start new thread for this small question:

    I have the source code tree of existing project, where every .cpp file for class, inherited from QObject, ends with inclusion of "class_name.moc" file.
    I try to make the Qt project file to use with QtCreator for this sources.
    The problem is in that qmake generates makefile, where *.cpp file depends on corresponding *.moc file, but the *,moc file rules only generated for *.cpp, wich declares private classes, inherited from QObject.

    Is it possible to generate makefile with rules to make *.moc files for every *.cpp with *.moc inclusion?

    Example:
    class1.h
    Qt Code:
    1. #include <qt4/QtCore/QObject>
    2. class Class1 : public QObject
    3. {
    4. Q_OBJECT
    5. public:
    6. Class1();
    7. };
    To copy to clipboard, switch view to plain text mode 

    class1.cpp
    Qt Code:
    1. #include "class1.h"
    2.  
    3. Class1::Class1()
    4. {
    5. }
    6. #include "class1.moc"
    To copy to clipboard, switch view to plain text mode 

    class1.pro
    Qt Code:
    1. TEMPLATE = lib
    2. INCLUDEPATH += .
    3.  
    4. HEADERS += class1.h
    5. SOURCES += class1.cpp
    To copy to clipboard, switch view to plain text mode 

    qmake
    make
    ...
    No rule to make target `class1.moc', needed by `class1.o'.

    But if cpp will be modified:
    class1.cpp
    Qt Code:
    1. #include "class1.h"
    2.  
    3. class Private : public QObject
    4. {
    5. Q_OBJECT
    6. };
    7.  
    8. Class1::Class1()
    9. {
    10. }
    11.  
    12. #include "class1.moc"
    To copy to clipboard, switch view to plain text mode 
    then lib is generated correctly.

  18. #17
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    I have seen such #includes, too, but, luckily, I didn't need to compile it I am still a beginner but, IMO, the *.moc files are some relic of Qt3. In a Qt4 project, you do not create *.moc files. AFAIK, the *.moc files aren't a part of a Qt4 project directly: you find files like moc_class1.o in the compiled project but no class1.moc file.

    I recommend checking whether the *.moc files contain something what should be in your *.cpp and *.hpp files. If they do then update the source files accordingly. If they don't (they contain only dependencies, includes and similar things) then comment all "#include something.moc" out, create a Qt4 project, add all sources and headers and compile. You should pass (if it is a Qt3 project, you might need the Qt3 support). The MOC info should be processed by qmake without your intervention.

  19. #18
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qmake behavior

    Quote Originally Posted by Radek View Post
    IMO, the *.moc files are some relic of Qt3.
    No, they are just a different way of dealing with the code generated by MOC.

    Without the include the behavior is to generate cpp files which are then compiled separately and linked like any other object file.

    The alternative with the include is used in three scenarios:
    1) when the Q_OBJECT using class declaration is inside the cpp file, not in a header
    2) when the code generated by moc needs to see some declarations that are private to the cpp file
    3) to speed up builds (no extra invocation of compiler for the moc generated file)

    Not sure why it doesn't work for starling13 though.

    Cheers,
    _

Similar Threads

  1. QMAKE FLAGS in qmake.conf for solaris-cc-64 uses old flags
    By qmake_query in forum Installation and Deployment
    Replies: 0
    Last Post: 16th October 2012, 09:11
  2. QGraphicsView Behavior
    By chaoticbob in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2009, 10:23
  3. qmake DESTDIR permissions behavior (Unix)
    By wdezell in forum Qt Tools
    Replies: 3
    Last Post: 9th March 2009, 14:59
  4. Odd behavior...
    By TemporalBeing in forum Qt Programming
    Replies: 0
    Last Post: 28th February 2009, 00:45
  5. QTreeView behavior
    By killerwookie99 in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 20:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.