[MacPorts] #46951: finance/bitcoin: Problems compiling against Qt4

MacPorts noreply at macports.org
Fri Apr 26 04:54:17 UTC 2019


#46951: finance/bitcoin: Problems compiling against Qt4
--------------------------+-------------------
  Reporter:  easye        |      Owner:  easye
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:
Resolution:               |   Keywords:
      Port:  bitcoin      |
--------------------------+-------------------

Comment (by kencu):

 This error occurs because the older `moc` program in `qt4`, which is
 essentially a preprocessor, does not understand the more complicated macro
 substitution that is being used in certain parts of newer versions of
 `boost`.

 `boost` has decided this is not their error to fix. `qt5` has an upgrade
 `moc` program and it understands the fancy business going on in the
 `boost` headers. It is reported that this improved `moc` will never be
 backported to `qt4`.

 The only solution is to block the problematic boost header from being
 preprocessed by `qt4`'s `moc`. If there are not too many instances of
 `#include <boost/xyz>` then you can wrap the header with
 {{{
 #ifndef Q_MOC_RUN
 #include <boost/myfailingheader.h>
 #endif
 }}}
 and that basically makes `moc` skip over the header, but somehow it still
 works out in the end that the header is used.

 If you have a lot of these `#include <boost/xyx.h>` then that approach can
 get mighty tedious quickly.

 This
 [https://bugreports.qt.io/browse/QTBUG-22829?focusedCommentId=192942&page=com.atlassian.jira.plugin.system.issuetabpanels
 %3Acomment-tabpanel#comment-192942 discussion] suggests you can wrap `moc`
 and add a define to it's implementation to make `moc` skip the problematic
 header series:
 {{{
 QMAKE_MOC = /path/to/moc -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
 }}}

 For my purposes, I just hacked the boost header directly for the duration
 of the problem build. This header that was causing all the errors for me
 was this one:
 {{{
 /opt/local/include/boost/type_traits/detail/has_binary_operator.hpp
 }}}

 so I added this at the top:
 {{{
 #ifndef Q_MOC_RUN
 }}}
 and this at the bottom
 {{{
 #endif
 }}}
 and the build completed without a hiccup.

 Now -- clearly I should remove that guard after the `qt4` build has
 completed, to get back to stock `boost` headers. But I will admit I'm
 rather tempted to just leave it there, because it looks like it can do no
 harm (what else is ever going to define `Q_MOC_RUN` other than `moc`)...
 but I guess `qt5`'s `moc` might, so there's a reason to remove it.

 I have been trying to come up with a fancy method to wrap that header in a
 block automatically, and so far, I can't.

 But anyway, there are several workarounds for the `BOOST_JOIN` problem
 with `qt4`.

-- 
Ticket URL: <https://trac.macports.org/ticket/46951#comment:8>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list