Boost logo

Boost-Build :

Subject: [Boost-build] qt5.jam moc call bug
From: Thomas Bretgeld (thomas.bretgeld_at_[hidden])
Date: 2014-01-16 06:20:06


today I was trying to compile a simple Qt5 program consisting of a main.cpp together with an empty main window subclass. I have used Qt 5.2.0 as a
binary 32bit install under Ubuntu 12.04. Compilation doesn't finish - instead bjam just hangs forever. However a simple "Hello World" app consisting
of a single main.cpp that just opens a QLabel as the root window does compile fine. I have searched for the error and it seems that the qt5.jam moc
call is not finishing. bjam -n reveals the call that doesn't terminate:

/usr/local/Qt/Qt-5.2.0/5.2.0/gcc/bin/moc -f GUI/MainWindow.h -o ../build/Qt5Project/gcc-4.6/release/threading-multi/GUI/moc_MainWindow.cpp

Running this command manually also never finishes.

/usr/local/Qt/Qt-5.2.0/5.2.0/gcc/bin/moc --help reveals:

Usage: /usr/local/Qt/ActiveQtConfigurationGvp/bin/moc [options] [header-file] [@option-file]
Qt Meta Object Compiler version 67 (Qt 5.2.0)

   -h, --help Displays this help.
   -v, --version Displays version information.
   -o <file> Write output to file rather than stdout.
   -I <dir> Add dir to the include path for header files.
   -F <framework> Add Mac framework to the include path for header fil
   -E Preprocess only; do not generate meta object code.
   -D <macro[=def]> Define macro, with optional definition.
   -U <macro> Undefine macro.
   -M <key=value> Add key/value pair to plugin meta data
   -i Do not generate an #include statement.
   -p <path> Path prefix for included file.
   -f <file> Force #include [optional <file>] (overwrite default)
   -b <file> Prepend #include <file> (preserve default include).
   -n <which> Do not display notes (-nn) or warnings (-nw). Compat
                            ibility option.
   --no-notes Do not display notes.
   --no-warnings Do not display warnings (implies --no-notes).
   --ignore-option-clashes Ignore all options that conflict with compilers, lik
                            e -pthread conflicting with moc's -p option.

   [header-file] Header file to read from, otherwise stdin.
   [@option-file] Read additional options from option-file.

So, I guess the "-f" option is wrong here and it causes to wait moc for input to appear on stdin instead of using the supplied filename. Removing the
"-f" from qt5.jam in line 683 solves the problem for this simple program (haven't tried a bigger project yet).

However I am not convinced that this is the right fix to the problem. It's a bit confusing since the qt5.jam contains explicit comments that this
option has been put in there intentionally:

# Processes headers to create Qt MetaObject information. Qt5-moc has its
# c++-parser, so pass INCLUDES and DEFINES.
# We use response file with one INCLUDE/DEFINE per line
actions moc
     $(.BINPREFIX[-1])/moc -f $(>) -o $(<) @"@($(<).rsp:E=-D$(DEFINES)$(.nl) -I$(INCLUDES:T)$(.nl))"

# When moccing files for include only, we don't need -f, otherwise the generated
# code will include the .cpp and we'll get duplicated symbols.
     $(.BINPREFIX[-1])/moc $(>) -o $(<) @"@($(<).rsp:E=-D$(DEFINES)$(.nl) -I$(INCLUDES:T)$(.nl))"

Can someone clarify, if removing the "-f" is the right solution? It may also be that somewhere else in the qt5.jam the wrong moc action is picked,
which could as well be the source of this error.

Best regards,
Thomas Bretgeld

PS: I am using the bjam from boost 1.55.0

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at