[semi-solved] Qt5 moc error in combination with boost
-
Also having the same issue with Qt 5 and 1.52 version of boost. Qt 4.8 works fine. Unfortunately adding compiler guards around all the boost includes isn't really a practical solution for me since boost usage is quite extensive.
-
Thought I'd add a little info for anyone else having this issue after doing some research.
First, this is a known MOC issue. The MOC can't expand some of the macros used in the Boost library. I believe the reason Qt 4.8 works is that a workaround for specific Boost macro definitions was added to the MOC configuration for that version.
What you need to do to work around this issue: As stated above, use Q_MOC_RUN to comment out problematic headers. You ONLY need to use Q_MOC_RUN in files that produce a moc file (e.g. myheader.h will produce moc_myheader.cpp). You can limit the hack to just those files. So you don't need to #ifndef all usages of Boost headers in your project which limits the pain of implementing this solution quite a bit.
-
Today i downloaded Qt 5 sources with GIT using git://gitorious.org/qt/qt5.git link. After successfull build of it and checking that "Hello-World" apps work okey, i have encountered the same error in my project that uses "boost::function" feature every where.
The problem looks like exactly the same as described here. Using suggested workaround (#ifndef Q_MOC_RUN ....) is realy annoying and is not acceptable in some cases for me.
But corresponding bug report https://bugreports.qt-project.org/browse/QTBUG-29331 was closed due they say fixed it!
My platform: Windows 7 x32, Qt v5.0.2, Boost Libs v1.51
Should i create another bugreport? -
[quote author="Avassen" date="1363949863"]Today i downloaded Qt 5 sources with GIT using git://gitorious.org/qt/qt5.git link. After successfull build of it and checking that "Hello-World" apps work okey, i have encountered the same error in my project that uses "boost::function" feature every where.
The problem looks like exactly the same as described here. Using suggested workaround (#ifndef Q_MOC_RUN ....) is realy annoying and is not acceptable in some cases for me.
But corresponding bug report https://bugreports.qt-project.org/browse/QTBUG-29331 was closed due they say fixed it!
My platform: Windows 7 x32, Qt v5.0.2, Boost Libs v1.51
Should i create another bugreport?[/quote]The bug report you are referencing is open and has the priority P2: Important .
There was a discussion at the beginning, that might be a duplicate and fixed in Qt 5.0.2. However, the next comment states already the opposite. Checking the timeline makes clear that there is some possibility of cross posting within minutes/hours.[edited, duplicate quote removed, koahnig]
-
Yes sure, it's cross-posting within minutes/hours by me))
And after my comment in the bug-report Olivier Goffart had opened this bugreport (it was closed before due he said it seemed to be duplicate of already fixed one).Also I've found that very common and one of most used boost-libs "boost::thread" and "boost::mutex" causes the same conflict! Big problem that my QObjects use many classes that have boost::thread and boost::mutex members. And they cannot be "forward-defined" for workaround or "include-guarded" with Q_MOC_RUN, described above.. (((
So very small part of people using Boost libraries in their projects can use Qt 5 lib and GUI at the moment ((...
Please! Help needed, now my project is in deadlock while trying to migrate from Qt 4.8.4 to Qt 5.0.2 due to this collision...
-
[quote author="charleyb" date="1363968657"]+1 to @Avassen, we also are porting from 4.8.4 to 5.0.1 (soon 5.0.2), and this compile error is a show-stopper. Is there a position on addressing this?[/quote]
You can vote on "JIRA":https://bugreports.qt-project.org for the bug report. -
[quote author="Avassen" date="1363962048"]Yes sure, it's cross-posting within minutes/hours by me))
And after my comment in the bug-report Olivier Goffart had opened this bugreport (it was closed before due he said it seemed to be duplicate of already fixed one).
[/quote]
No offence intended. :-)
It is more a summary of what might have happened and the identity of authors is not obvious.
Certainly it is also in my interest that boost and Qt will cooperate. Therefore it got my vote. -
The workaround does not work for me. Is there any additional news on this?
After upgrading to Qt 5.0.1. I am not only dealing with this issue but with hundreds of syntax and compiler errors in what used to be stable and functional code. I think the Boost error is the root cause (the Boost argument mismatch errors are reported before any of the others) but at this rate I will be better off going back to 4.8 than to try and sort it out in 5.0.1....
-
Like I have posted here: http://qt-project.org/forums/viewthread/27125/#151289
The issue is with the moc.exe file, in Qt 5.2 beta they have changed it from error to warning, so now you can compile.
You can either upgrade to 5.2 or you can just get the moc.exe file and put it in the 5.1.1 bin folder like I did, it works.