Discussion:
qt and scons not calling moc
Michael Rutman
2010-08-24 17:48:56 UTC
Permalink
I have simplified this to a simple example. I know it won't actually compile but the moc step should still be run.

The SConstruct is:

env = Environment(tools = ['default','qt'],
QTDIR="~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/"
)

env['QT_DEBUG'] = 1
env.Program(Split('qttest.cpp'))


The source for qttest.cpp is

class Foo
{
Q_OBJECT
};



Like I said, I simplified it down to the most trivial example I could think of to force the creation of a moc file.

My output is:

scons
scons: Reading SConscript files ...
scons: qt: no header for 'qttest.cpp'.
scons: qt: found Q_OBJECT macro in 'qttest.cpp', moc'ing to '['qttest.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o qttest.o -c -I~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/include qttest.cpp
qttest.cpp:4: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
qttest.cpp:5: error: expected ';' before '}' token
qttest.cpp:5: error: expected `;' before '}' token
scons: *** [qttest.o] Error 1
scons: building terminated because of errors.


So, the qt found that it needs to create the qttest.moc file, it just doesn't make it.

I have tried adding qttest.moc to env.Program. Then I get:

scons: qt: 'qttest.moc' seems to be a binary. Discarded.


Any simple examples that show a moc actually happen?

Thanks

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650747

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Matthieu Brucher
2010-08-24 17:56:24 UTC
Permalink
Hi,

It seems that you can compile qttest.cpp. Try fixing this file first,
then everything may work.
It is also better to run moc on header files than on sources.

Matthieu
I have simplified this to a simple example.  I know it won't actually compile but the moc step should still be run.
env = Environment(tools = ['default','qt'],
                         QTDIR="~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/"
      )
env['QT_DEBUG'] = 1
env.Program(Split('qttest.cpp'))
The source for qttest.cpp is
class Foo
{
   Q_OBJECT
};
Like I said, I simplified it down to the most trivial example I could think of to force the creation of a moc file.
scons
scons: Reading SConscript files ...
scons: qt: no header for 'qttest.cpp'.
scons: qt: found Q_OBJECT macro in 'qttest.cpp', moc'ing to '['qttest.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o qttest.o -c -I~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/include qttest.cpp
qttest.cpp:4: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
qttest.cpp:5: error: expected ';' before '}' token
qttest.cpp:5: error: expected `;' before '}' token
scons: *** [qttest.o] Error 1
scons: building terminated because of errors.
So, the qt found that it needs to create the qttest.moc file, it just doesn't make it.
scons: qt: 'qttest.moc' seems to be a binary. Discarded.
Any simple examples that show a moc actually happen?
Thanks
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650747
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650748

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Michael Rutman
2010-08-24 18:18:51 UTC
Permalink
OK,

I oversimplified the problem.

It appears the problem is that the source I picked up does a #include "qttest.moc" to get the qttest.moc to be linked in. That fails because qttest.moc does not exist when qttest.cpp is compiled. But if qttest.cpp fails to compile then the moc is never run to generate that file.

So, how do I tell scons to run moc before trying to compile qttest.cpp?

And yes, if I remove the #include line qttest.cpp compiles and moc is run, then the link fails because the qttest.moc file is not compiled and linked in.

Thanks for the help.
Post by Matthieu Brucher
Hi,
It seems that you can compile qttest.cpp. Try fixing this file first,
then everything may work.
It is also better to run moc on header files than on sources.
Matthieu
Post by Michael Rutman
I have simplified this to a simple example. I know it won't actually compile but the moc step should still be run.
env = Environment(tools = ['default','qt'],
QTDIR="~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/"
)
env['QT_DEBUG'] = 1
env.Program(Split('qttest.cpp'))
The source for qttest.cpp is
class Foo
{
Q_OBJECT
};
Like I said, I simplified it down to the most trivial example I could think of to force the creation of a moc file.
scons
scons: Reading SConscript files ...
scons: qt: no header for 'qttest.cpp'.
scons: qt: found Q_OBJECT macro in 'qttest.cpp', moc'ing to '['qttest.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o qttest.o -c -I~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/include qttest.cpp
qttest.cpp:4: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
qttest.cpp:5: error: expected ';' before '}' token
qttest.cpp:5: error: expected `;' before '}' token
scons: *** [qttest.o] Error 1
scons: building terminated because of errors.
So, the qt found that it needs to create the qttest.moc file, it just doesn't make it.
scons: qt: 'qttest.moc' seems to be a binary. Discarded.
Any simple examples that show a moc actually happen?
Thanks
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650747
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650748
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650750

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Matthieu Brucher
2010-08-24 19:05:57 UTC
Permalink
With Qt4, it is not the recommanded way to include the moc file inside
the cpp file.
Try using a header file that will be moc-ed.

Matthieu
Post by Michael Rutman
OK,
I oversimplified the problem.
It appears the problem is that the source I picked up does a #include
"qttest.moc" to get the qttest.moc to be linked in.  That fails because
qttest.moc does not exist when qttest.cpp is compiled.  But if qttest.cpp
fails to compile then the moc is never run to generate that file.
So, how do I tell scons to run moc before trying to compile qttest.cpp?
And yes, if I remove the #include line qttest.cpp compiles and moc is run,
then the link fails because the qttest.moc file is not compiled and linked
in.
Thanks for the help.
Hi,
It seems that you can compile qttest.cpp. Try fixing this file first,
then everything may work.
It is also better to run moc on header files than on sources.
Matthieu
I have simplified this to a simple example.  I know it won't actually
compile but the moc step should still be run.
env = Environment(tools = ['default','qt'],
 QTDIR="~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/"
      )
env['QT_DEBUG'] = 1
env.Program(Split('qttest.cpp'))
The source for qttest.cpp is
class Foo
{
   Q_OBJECT
};
Like I said, I simplified it down to the most trivial example I could
think of to force the creation of a moc file.
scons
scons: Reading SConscript files ...
scons: qt: no header for 'qttest.cpp'.
scons: qt: found Q_OBJECT macro in 'qttest.cpp', moc'ing to
'['qttest.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o qttest.o -c
-I~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/include qttest.cpp
qttest.cpp:4: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
qttest.cpp:5: error: expected ';' before '}' token
qttest.cpp:5: error: expected `;' before '}' token
scons: *** [qttest.o] Error 1
scons: building terminated because of errors.
So, the qt found that it needs to create the qttest.moc file, it just doesn't make it.
scons: qt: 'qttest.moc' seems to be a binary. Discarded.
Any simple examples that show a moc actually happen?
Thanks
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650747
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650748
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650761

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Michael Rutman
2010-08-24 19:31:35 UTC
Permalink
OK, got it working. Thanks.
Post by Matthieu Brucher
With Qt4, it is not the recommanded way to include the moc file inside
the cpp file.
Try using a header file that will be moc-ed.
Matthieu
Post by Michael Rutman
OK,
I oversimplified the problem.
It appears the problem is that the source I picked up does a #include
"qttest.moc" to get the qttest.moc to be linked in. That fails because
qttest.moc does not exist when qttest.cpp is compiled. But if qttest.cpp
fails to compile then the moc is never run to generate that file.
So, how do I tell scons to run moc before trying to compile qttest.cpp?
And yes, if I remove the #include line qttest.cpp compiles and moc is run,
then the link fails because the qttest.moc file is not compiled and linked
in.
Thanks for the help.
Hi,
It seems that you can compile qttest.cpp. Try fixing this file first,
then everything may work.
It is also better to run moc on header files than on sources.
Matthieu
Post by Michael Rutman
I have simplified this to a simple example. I know it won't actually
compile but the moc step should still be run.
env = Environment(tools = ['default','qt'],
QTDIR="~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/"
)
env['QT_DEBUG'] = 1
env.Program(Split('qttest.cpp'))
The source for qttest.cpp is
class Foo
{
Q_OBJECT
};
Like I said, I simplified it down to the most trivial example I could
think of to force the creation of a moc file.
scons
scons: Reading SConscript files ...
scons: qt: no header for 'qttest.cpp'.
scons: qt: found Q_OBJECT macro in 'qttest.cpp', moc'ing to
'['qttest.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o qttest.o -c
-I~miker/widevine/ThirdParty/qt-all-opensource-src-4.5.3/include qttest.cpp
qttest.cpp:4: error: ISO C++ forbids declaration of 'Q_OBJECT' with no type
qttest.cpp:5: error: expected ';' before '}' token
qttest.cpp:5: error: expected `;' before '}' token
scons: *** [qttest.o] Error 1
scons: building terminated because of errors.
So, the qt found that it needs to create the qttest.moc file, it just
doesn't make it.
scons: qt: 'qttest.moc' seems to be a binary. Discarded.
Any simple examples that show a moc actually happen?
Thanks
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650747
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650748
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650761
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650766

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Thomas Berg
2010-08-24 19:18:30 UTC
Permalink
Post by Michael Rutman
So, how do I tell scons to run moc before trying to compile qttest.cpp?
Not sure which version of the qt tool you are using, but in the qt4
tool I'm using this is achieved by explicit call:
env.Moc4('qttest.cpp')

If the variant directory is in the include path (or if you don't use
variant directories), scons should figure out that this needs to be
generated before it attempts to compile the source file.

Only for headers does the qt4 tool automatically run moc for you.

Hope this helps,
Thomas

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650764

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Michael Rutman
2010-08-24 19:32:19 UTC
Permalink
I am using scons v1.2.0r3842.

I don't have a qt4 builder, just a qt builder.

I will move my object to the header and things will be good, thanks.
Post by Thomas Berg
Post by Michael Rutman
So, how do I tell scons to run moc before trying to compile qttest.cpp?
Not sure which version of the qt tool you are using, but in the qt4
env.Moc4('qttest.cpp')
If the variant directory is in the include path (or if you don't use
variant directories), scons should figure out that this needs to be
generated before it attempts to compile the source file.
Only for headers does the qt4 tool automatically run moc for you.
Hope this helps,
Thomas
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650764
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650767

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Dirk Baechle
2010-08-25 08:54:56 UTC
Permalink
Hi,

the latest version of the Qt4 tool does not even require the explicit Moc4 call...it has a mode where files get automoc'ed based on #include directives...for headers and CPP files as well (if you regard some prefix/suffix conventions).

If this got you interested, check out the ToolsIndex page and the Qt4Tool page in the Wiki.

Best regards,

Dirk

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2650969

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Loading...