[Scons-users] QtDir not found

Philipp Kraus philipp.kraus at flashpixx.de
Thu Apr 4 06:03:47 EDT 2013


On 2013-04-04 10:36:34 +0200, Philipp Kraus said:


> Hi,

>

> I try to use Qt 5.0.1 with Scons 2.3.0 & MinGW on Windows (test installation):

>

> I create the env object like

>

> env = Environment( tools=["mingw", "qt"] )

>

> env.AppendUnique(CXXFLAGS = ["-O2"], )

> env.Replace(QTDIR = os.path.join("..", "Qt", "5.0.1", "mingw47_32"))

>

> The dump of env shows for the Qt part

>

> 'QTDIR': '..\\Qt\\5.0.1\\mingw47_32',

> 'QT_AUTOSCAN': 1,

> 'QT_BINPATH': '$QTDIR\\bin',

> 'QT_CPPPATH': '$QTDIR\\include',

> 'QT_LIB': 'qt',

> 'QT_LIBPATH': '$QTDIR\\lib',

> 'QT_MOC': '$QT_BINPATH\\moc',

> 'QT_MOCCXXPREFIX': '',

> 'QT_MOCCXXSUFFIX': '.moc',

> 'QT_MOCFROMCXXCOM': [ ['$QT_MOC', '$QT_MOCFROMCXXFLAGS', '-o',

> '${TARGETS[0]}' , '$SOURCE'], <SCons.Action.FunctionAction object at

> 0x01CFB1D0>],

> 'QT_MOCFROMCXXFLAGS': ['-i'],

> 'QT_MOCFROMHCOM': '$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE',

> 'QT_MOCFROMHFLAGS': [],

> 'QT_MOCHPREFIX': 'moc_',

> 'QT_MOCHSUFFIX': '$CXXFILESUFFIX',

> 'QT_UIC': '$QT_BINPATH\\uic',

> 'QT_UICCOM': [ ['$QT_UIC', '$QT_UICDECLFLAGS', '-o', '${TARGETS[0]}',

> '$SOURCE'], ['$QT_UIC', '$QT_UICIMPLFLAGS', '-impl',

> '${TARGETS[0].file}', '-o', '${TARGETS[1]}', '$SOURCE'], ['$QT_MOC',

> '$QT_MOCFROMHFLAGS', '-o', '${TARGETS[2]}', '${TARGETS[0]}']],

> 'QT_UICDECLFLAGS': [],

> 'QT_UICDECLPREFIX': '',

> 'QT_UICDECLSUFFIX': '.h',

> 'QT_UICIMPLFLAGS': [],

> 'QT_UICIMPLPREFIX': 'uic_',

> 'QT_UICIMPLSUFFIX': '$CXXFILESUFFIX',

> 'QT_UISUFFIX': '.ui',

>

> seems to be fine. but creates the warning:

>

> scons: warning: Could not detect qt, using empty QTDIR

>

> but moc etc runs without errors, but on this default settings, Scons

> try to link always to the "qt" library, but on Qt 5 this does not exist.

> I set the linker to

> env.Replace(QT_LIB = ["Qt5Widgets", "Qt5Gui", "Qt5Core"])

>

> All problems are only "defective appearance"



Scons creates in this case with the UI build a problem, because Scons
deletes some existing header files.

I have checked Qt Creator calls and IMHO the settings of the UI build should be

env.Replace(QT_UICCOM = [['$QT_UIC', '$QT_UICDECLFLAGS',
'$SOURCE', '-o', '$QT_UICIMPLPREFIX${TARGETS[0]}']])
env.Replace(QT_UICIMPLPREFIX = 'ui_')

The Creator uses the UI header files with the prefix "ui_", Scons uses
"uic_" (so because consistence, I would like to use ui_).
A big problem is, that Scons does not use in the UICOM the
UICIMPLPREFIX (the prefix is not used on default settings). This
overwrites my header files:

I have this file structure:
MainWindow.cpp
MainWindow.h
MainWindow.ui

Without the prefix option, the uic call creates uic -o MainWindow.h
Mainwindow.ui and so my existing header is replaced by the uic
generated header. The generated header
is a "header-only" file, so in my CPP I can use it directly with
#include "ui_MainWindow.h", so the other uic commands in the default
Scons settings are not needed.

The next problem is, that Scons deletes anyway the MainWindow.h (I
don't find the code call, which deletes the header). I call in the main
SConstruct

env.Program("qtbsp", Glob("*.cpp")+Glob("*.ui") )

The output shows:


..\Qt\5.0.1\mingw47_32\bin\uic MainWindow.ui -o ui_MainWindow.h
g++ -o MainWindow.o -c -O2 -DNDEBUG -DQT_NO_DEBUG
-IC:\Users\Administrator\Desktop\Qt\5.0.1\mingw47_32\include
-IC:\Users\Administrator\Desktop\Boost\include MainWindow.cpp
MainWindow.cpp:1:24: fatal error: MainWindow.h: No such file or directory
compilation terminated.

between the call uic call and the g++ command, Scons deletes the
MainWinow.h file, I don't know why. If I compile the project with
env.Program("qtbsp", Glob("*.cpp")+Glob("*.ui") )
restore after the error my header files and replace this Program line to
env.Program("qtbsp", Glob("*.cpp") )
my project can be compiled and linked.

If I run after that scons -c, my header file is deleted again. So there
must be a problem with the with the target generation / updating in the
buildprocess. The problem exists
only on the uic use.

Hope for a fix, thanks a lot

Phil




More information about the Scons-users mailing list