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?
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?
Re: qmake incorrectly generates Makefile with instruction to build the moc tool
:confused: 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?
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
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.
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.
Re: qmake incorrectly generates Makefile with instruction to build the moc tool
Quote:
Originally Posted by
paulocarvalho_br_2009
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
Re: qmake incorrectly generates Makefile with instruction to build the moc tool
Quote:
Originally Posted by
rknowles
- 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
- 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
- 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
- What's in 'qt.conf' for 'Prefix'?
Where is it located? I can't find it.
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:
Code:
isEmpty(QMAKE_MOC) {
win32:QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe
else:QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
}
Notice that you may override it by defining QMAKE_MOC.
Re: qmake incorrectly generates Makefile with instruction to build the moc tool
Quote:
Originally Posted by
wysota
...
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
Re: qmake incorrectly generates Makefile with instruction to build the moc tool
Re: qmake incorrectly generates Makefile with instruction to build the moc tool
Quote:
Originally Posted by
paulocarvalho_br_2009
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 :)