Results 1 to 13 of 13

Thread: qmake incorrectly generates Makefile with instruction to build the moc tool

  1. #1
    Join Date
    May 2009
    Location
    Rio de Janeiro/RJ/Brazil
    Posts
    20
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question qmake incorrectly generates Makefile with instruction to build the moc tool

    Greetings,

    1) I downloaded the Qt source code;
    2) I ran the config script;
    3) Built bootstrap;
    4) Built moc;
    5) Built qmake;

    Then I used that qmake to generate a Makefile for some project, but that Makefile has instructions to build the moc tool (build target) before compiling the moc_*.cpp files. That makes no sense to me since moc was already built and my older qmake does not generate such instructions.

    Question: How do I make qmake generate the Makefiles using the moc that was already built in the step 4 instead of building the moc tool?

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Answer: Rephrase and expand your question.

    Counter-question: Take a look at your question. How would you answer it?
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    May 2009
    Location
    Rio de Janeiro/RJ/Brazil
    Posts
    20
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Dunno. I haven't figured out the answer yet.

    Question: How do I make qmake generate Makefiles that call the moc tool that was already built in the step 4 instead of trying to re-build the moc tool?

    Is it clearer now?

  4. #4
    Join Date
    Jun 2007
    Location
    Massachusetts, USA
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Is this just a misunderstanding of how 'make' works? A makefile rule for moc makes sense because running the moc compiler depends on moc itself being built. But- when you actually run make for your application moc has already been built (step 4), so make should not try to rebuild moc but will call it to create the moc-files for your application. Have you tried 'make' yet? Is there incorrect behavior when you run it, or are you just concerned because of the contents of the makefile?

    - Dick

  5. #5
    Join Date
    May 2009
    Location
    Rio de Janeiro/RJ/Brazil
    Posts
    20
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    The generated Makefile seems to be correct. However it expects the moc tool to be in

    $QTDIR/src/tools/moc (this path does not exist)

    instead of

    $QTDIR/bin/moc (where the moc binary is)

    Thus the build fails because the generated Makefile instructs incorrectly.

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

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    It expects it to be where you configured it to be when running configure. Why are you trying to build Qt "manually"? All that is required is configure, make and make install. The first two with optional parameters.
    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
    Jun 2007
    Location
    Massachusetts, USA
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Quote Originally Posted by paulocarvalho_br_2009 View Post
    The generated Makefile seems to be correct. However it expects the moc tool to be in

    $QTDIR/src/tools/moc (this path does not exist)

    instead of

    $QTDIR/bin/moc (where the moc binary is)

    Thus the build fails because the generated Makefile instructs incorrectly.
    Some things to check.

    - Does the makefile literally say "$QTDIR/src/tools/moc" or is there an actual path,i.e "/someplace/else/src/tools/moc"?
    - Where is qmake located?
    - Are you setting QMAKESPEC?
    - What's in 'qt.conf' for 'Prefix'?

    Dick

  8. #8
    Join Date
    May 2009
    Location
    Rio de Janeiro/RJ/Brazil
    Posts
    20
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Quote Originally Posted by rknowles View Post
    - Does the makefile literally say "$QTDIR/src/tools/moc" or is there an actual path,i.e
    "/someplace/else/src/tools/moc"?
    It is actually $(QTDIR)/src/tools/moc, notice the parenthesis, denoting de usage of the environment variable.

    Quote Originally Posted by rknowles View Post
    - Where is qmake located?
    The which qmake command yielded /apps/qt4/LinuxE_64/qt-4.5.0/bin/qmake, the part in bold face corresponds to the contents of $QTDIR.

    Quote Originally Posted by rknowles View Post
    - Are you setting QMAKESPEC?
    No. I use the -spec option to explicitly use a mkspec file (from my local build and not from $QTDIR, does it matter?) because we compile for several platforms. For this issue I'm specifically using linux-g++-64.

    Quote Originally Posted by rknowles View Post
    - What's in 'qt.conf' for 'Prefix'?
    Where is it located? I can't find it.

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

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    You may have different moc binaries and different qmake binaries. qmake creates rules for compilation using the moc tool that is related to its own (qmake) binary. It expects it to be in the same path. Thanks to that by changing the qmake tool you run, you may change the Qt installation that will be used to build the project. I suspect that if you move your qmake to /usr/bin, then it will use /usr/bin/moc.

    Here is how moc path is defined:
    qmake Code:
    1. isEmpty(QMAKE_MOC) {
    2. win32:QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe
    3. else:QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
    4. }
    To copy to clipboard, switch view to plain text mode 

    Notice that you may override it by defining QMAKE_MOC.
    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.


  10. The following user says thank you to wysota for this useful post:

    paulocarvalho_br_2009 (7th July 2009)

  11. #10
    Join Date
    Jun 2007
    Location
    Massachusetts, USA
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Quote Originally Posted by wysota View Post
    ...

    Notice that you may override it by defining QMAKE_MOC.
    I looked for a way to override and did not find this in the documentation. Did I just miss it?

    - Dick

  12. #11
    Join Date
    May 2009
    Location
    Rio de Janeiro/RJ/Brazil
    Posts
    20
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    Quote Originally Posted by wysota View Post
    Why are you trying to build Qt "manually"?
    Because I'm making changes to qmake itself, hence the confusion from my part. By the way, it's been a month since I made my merge request and it's still open:

    http://qt.gitorious.org/qt/qt/merge_requests/569

    Quote Originally Posted by rknowles View Post
    I looked for a way to override and did not find this in the documentation.
    Indeed, not there:

    http://doc.trolltech.com/4.5/qmake-v...reference.html

    Quote Originally Posted by wysota View Post
    Notice that you may override it by defining QMAKE_MOC.
    That solved the moc not found problem and all moc_*.cpp files have been generated and compiled. Thanks. But it would be important to include that variable in the qmake variable reference.
    Last edited by wysota; 7th July 2009 at 17:28.

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

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    It's not documented.
    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.


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

    Default Re: qmake incorrectly generates Makefile with instruction to build the moc tool

    Quote Originally Posted by paulocarvalho_br_2009 View Post
    But it would be important to include that variable in the qmake variable reference.
    I wouldn't agree here. There are literally hundreds of undocumented variables qmake uses that are referenced in different configuration files. But they are not part of qmake itself but rather of its configuration file set. Documenting variables you will probably never use would just make it harder to find the ones you would want to use.

    For instance there is this DBUS_ADAPTOR_HEADERS variable which is completely uninteresting
    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.


Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  2. Replies: 1
    Last Post: 11th January 2006, 14:15

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.