PDA

View Full Version : Missing qt/mocinclude.tmp file [Qt 5.5.1, Visual Studio 2010]



philw
15th June 2016, 01:53
In the course of our Qt4 to Qt 5.5.1 port, we're having a problem replicating a successful application build from one development machine to another.

On the 2nd machine, no qt/mocinclude.tmp file is being created (in the same directories where all the generated moc_.cpp and ui_.h files go).

WHY MIGHT THAT BE?

This is resulting in the following problem with the MOC compilation of Q_OBJECT class header files:


moc: Cannot open options file specified with @
list itemQCommandLineParser: argument list cannot be empty, it should contain at least the executable name


The .vcxproj files contain lines such as the following with a "@./qt/mocinclude.tmp" term:


<Command Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;Debug|x64&apos;">
setlocal&#x000D;&#x000A;if errorlevel 1 goto VCEnd&#x000D;&#x000A;C:\Riverware\tools\
Qt-551\qtbase\bin\moc.exe -DWIN32 -DWIN64 -DIL_STD -D_WIN32 -DCW_PRESTOPLOT -DCWDEBUG
-DUSE_NON_CONST -DQT_WEBKITWIDGETS_LIB -DQT_WEBKIT_LIB -DQT_PRINTSUPPORT_LIB
-DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_XML_LIB -DQT_CONCURRENT_LIB
-DQT_CORE_LIB -D_MSC_VER=1600 -D_WIN32 -D_WIN64 @./qt/mocinclude.tmp
AccountMgrDlg.hpp -o qt\moc_AccountMgrDlg.cpp&#x000D;&#x000A;if errorlevel 1 goto
VCEnd&#x000D;&#x000A;endlocal</Command>

We're using Visual Studio 2010. The first machine (on which Qt 5.5.1 was actually built) is Windows 7. The second machine is Windows 8.1.

We DO have a lot of "includes". This is from a relevant .pro file:


INCLUDEPATH += \
../Accounting \
../AccountingGUI \
../ClientServer \
../DbDmi \
../EngrObjs \
../GUI \
../Halibut \
../Opt \
../Optimize \
../OracleConnect \
../Q3GUI \
../QtAccounting \
../QtDmi \
../QtRpl \
../QtRun \
../QtSCT \
../QtUtils \
../Rcl \
../Remote \
../Rpl \
../RplExpression \
../RwDoc \
../RwOracle \
../RwQt \
../Servers \
../Sim \
../Units \
../Utils \
../VCXX \
C:/RiverWare/tools/RdfToExcel_Qt-551/include \
C:/RiverWare/tools/Qwt-612_Qt-551/src \
C:/RiverWare/tools/RepriseLM-12.0 \
C:/RiverWare/tools/CPLEX-125/cplex/include \
C:/RiverWare/tools/CPLEX-125/concert/include \
C:/RiverWare/tools/Stubs/include \
C:/RiverWare/tools/tcl-8.6.4/generic \
C:/RiverWare/tools/gdal-1.9.2/include \
C:/RiverWare/tools/netCDF-4.3.2/include \
C:/Riverware/tools/Quazip-0.7.1_Qt-551 \
C:/RiverWare/tools/protobuf-2.6.0/include \
C:/RiverWare/tools/icu-55.1/include \
$$[QT_INSTALL_PREFIX]/src/3rdparty/zlib

On the original machine, the generated qt/mocinclude.tmp files have this content:


-IC:/Riverware/tools/Qt-551/qtbase/mkspecs/win32-msvc2010
-IC:/Riverware/staff/philw/WinQt5Port3/QtAccounting
-IC:/Riverware/staff/philw/WinQt5Port3/Accounting
-IC:/Riverware/staff/philw/WinQt5Port3/AccountingGUI
-IC:/Riverware/staff/philw/WinQt5Port3/ClientServer
-IC:/Riverware/staff/philw/WinQt5Port3/DbDmi
-IC:/Riverware/staff/philw/WinQt5Port3/EngrObjs
-IC:/Riverware/staff/philw/WinQt5Port3/GUI
-IC:/Riverware/staff/philw/WinQt5Port3/Halibut
-IC:/Riverware/staff/philw/WinQt5Port3/Opt
-IC:/Riverware/staff/philw/WinQt5Port3/Optimize
-IC:/Riverware/staff/philw/WinQt5Port3/OracleConnect
-IC:/Riverware/staff/philw/WinQt5Port3/Q3GUI
-IC:/Riverware/staff/philw/WinQt5Port3/QtAccounting
-IC:/Riverware/staff/philw/WinQt5Port3/QtDmi
-IC:/Riverware/staff/philw/WinQt5Port3/QtRpl
-IC:/Riverware/staff/philw/WinQt5Port3/QtRun
-IC:/Riverware/staff/philw/WinQt5Port3/QtSCT
-IC:/Riverware/staff/philw/WinQt5Port3/QtUtils
-IC:/Riverware/staff/philw/WinQt5Port3/Rcl
-IC:/Riverware/staff/philw/WinQt5Port3/Remote
-IC:/Riverware/staff/philw/WinQt5Port3/Rpl
-IC:/Riverware/staff/philw/WinQt5Port3/RplExpression
-IC:/Riverware/staff/philw/WinQt5Port3/RwDoc
-IC:/Riverware/staff/philw/WinQt5Port3/RwOracle
-IC:/Riverware/staff/philw/WinQt5Port3/RwQt
-IC:/Riverware/staff/philw/WinQt5Port3/Servers
-IC:/Riverware/staff/philw/WinQt5Port3/Sim
-IC:/Riverware/staff/philw/WinQt5Port3/Units
-IC:/Riverware/staff/philw/WinQt5Port3/Utils
-IC:/Riverware/staff/philw/WinQt5Port3/VCXX
-IC:/RiverWare/tools/RdfToExcel_Qt-551/include
-IC:/RiverWare/tools/Qwt-612_Qt-551/src
-IC:/RiverWare/tools/RepriseLM-12.0
-IC:/RiverWare/tools/CPLEX-125/cplex/include
-IC:/RiverWare/tools/CPLEX-125/concert/include
-IC:/RiverWare/tools/Stubs/include
-IC:/RiverWare/tools/tcl-8.6.4/generic
-IC:/RiverWare/tools/gdal-1.9.2/include
-IC:/RiverWare/tools/netCDF-4.3.2/include
-IC:/Riverware/tools/Quazip-0.7.1_Qt-551
-IC:/RiverWare/tools/protobuf-2.6.0/include
-IC:/RiverWare/tools/icu-55.1/include
-IC:/Riverware/tools/Qt-551/qtbase/src/3rdparty/zlib
-IC:/RiverWare/tools/flexlm
-IC:/RiverWare/tools/Oracle-12c/include
-IC:/Riverware/tools/Qt-551/qtwebkit/include
-IC:/Riverware/tools/Qt-551/qtwebkit/include/QtWebKitWidgets
-IC:/Riverware/tools/Qt-551/qtbase/include
-IC:/Riverware/tools/Qt-551/qtbase/include/QtWebKitWidgets
-IC:/Riverware/tools/Qt-551/qtwebkit/include/QtWebKit
-IC:/Riverware/tools/Qt-551/qtbase/include/QtWebKit
-IC:/Riverware/tools/Qt-551/qtbase/include/QtPrintSupport
-IC:/Riverware/tools/Qt-551/qtbase/include/QtWidgets
-IC:/Riverware/tools/Qt-551/qtbase/include/QtGui
-IC:/Riverware/tools/Qt-551/qtbase/include/QtNetwork
-IC:/Riverware/tools/Qt-551/qtbase/include/QtXml
-IC:/Riverware/tools/Qt-551/qtbase/include/QtConcurrent
-IC:/Riverware/tools/Qt-551/qtbase/include/QtCore

d_stranz
15th June 2016, 18:58
- Do you have the Qt plugin for Visual Studio installed on the second machine?
- Are all the paths the same on both machines?
- Are the permissions and ownership of the GeneratedFiles directories correct?

My MOC commands in the vcxproj files don't look very much like this. Here's an example from one of my projects (with some extra CRLF added for readability):



<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filena me).cpp"
-DUNICODE -DWIN32 -DWIN64 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB
"-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore"
"-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"
</Command>

(This is likely from VS 2013, but the project files haven't changed much in recent versions of VS. I use an environment variable QT_DIR to point to the Qt distribution I am using for the build).

I would suggest that you try the following experiment:

- Do a "clean" without a rebuild
- Remove one of your Qt GUI classes from the project (using the right-click "remove" in Solution Browser), .h, .cpp, and .ui if present.
- Manually remove the generated files for it from the generated output directory if the clean didn't do it.
- Do a build (which will probably fail because of the missing class.
- Add the class files back in (Add existing item).
- Save all.

Examine the .vcxproj file and see what the MOC command for the newly-readded file looks like. If it is different from the original version, and trying to build the newly-added files succeeds, then you may have to do the same for all of the files for the QObject-based classes.

I have found that sometimes Visual Studio just gets confused when dealing with MOC, and the easiest (but most tedious) method is to remove / add to fix the problem. As a first step, going into the GeneratedFIles directories and manually deleting everything in them sometimes works, too.

philw
18th June 2016, 02:40
(I hadn't seen d_stranz's post before devising this work-around. See prior message. In any case -- THANKS SO MUCH for taking a look at this for us!)

To solve (or really, work-around) this problem, we modified qtbase\mkspecs\features\moc.prf

We first tried changing the name of the temporary include file mocinclude.tmp to mocinclude.opt (basically a patch that had been applied to Qt 5.6, I believe). That didn't help.

We then commented out the generation and use of that include path file, forcing -I arguments to moc.exe to all be put right on the command line invocation of that program (i.e. regardless of how many of those arguments there were). That worked for us.


# On Windows, put the includes into a .inc file which moc will read, if the project
# has too many includes. We do this to overcome a command-line limit on Win < XP
WIN_INCLUDETEMP=

# [Phil, 6-17-2016, skip the mocinclude file altogether]
# win32:count(MOC_INCLUDEPATH, 40, >) {
# WIN_INCLUDETEMP = $$MOC_DIR/mocinclude.opt
#
# WIN_INCLUDETEMP_CONT =
# for (inc, MOC_INCLUDEPATH): \
# WIN_INCLUDETEMP_CONT += -I$$inc
# write_file($$absolute_path($$WIN_INCLUDETEMP, $$OUT_PWD), WIN_INCLUDETEMP_CONT)|error("Aborting.")
# }

You must invoke qmake.exe on all Qt application project files after making this change to qtbase\mkspecs\features\moc.prf.

Notice that the original comment indicates that this mocinclude provision was introduced to address a command-line size limit on Windows versions before "XP". :) However, Qt Technical Support mentions to me that it would technically be possible to exceed the larger command line size limit of subsequent Windows versions, so it's not technically true that this mocinclude provision would never be needed.

We just couldn't get it to work for us. [Qt 5.5.1, Windows 8.1, Visual Studio 2010 Professional SP1]. The mocinclude.tmp (or .opt) file was absent (when we needed it to exist) when we attempted to build our application in Visual Studio. (See prior notes).