[Scons-users] Trouble building a qt based project.

Matias Iturburu matias.iturburu at tallertechnologies.com
Mon Oct 7 11:31:13 EDT 2013


I'm trying to make scons build me a project using the great qt4 tool (
https://bitbucket.org/dirkbaechle/scons_qt4/<https://bitbucket.org/dirkbaechle/scons_qt4/src>
).

This is how I'm creating my environment

env = Environment(tools=['default', 'qt4'])
env['QT_PRESENT'] = True

Export('env')

vars = Variables('SConfig')
Export('vars')
...

And this is my Sconscript:

Import ('env')
env.Append(CXXFLAGS = ['--std=c++0x'])
env.EnableQt4Modules(['QtCore','QtGui'])
deps = []
inc = (
env.Dir("."),
env.Dir("uiDirector"),
env.Dir("common"),
)
src = (
env.Glob('uiDirector/src/*.cpp'),
env.Glob('uiDirector/*.qrc'),
)
env.CreateObject('my-object', inc, src, deps)
main_src = env.Glob('main.cpp')
main_deps = deps + ['my-object']
env.CreateProgram('my-app', inc, main_src, main_deps)

Still I'm running into this message:

$ scons --verbose
scons: Reading SConscript files ...

scons: warning: QT4DIR variable is not defined, using moc executable as a
hint (QT4DIR=/usr)
File
"/home/matias/Proyectos/my-project/site_scons/site_tools/qt4/__init__.py",
line 395, in _detect
Install information:
bin dir : /home/matias/Proyectos/tmp/install/bin
lib dir : /home/matias/Proyectos/tmp/install/libs
headers dir: /home/matias/Proyectos/tmp/install/includes
doc dir : /home/matias/Proyectos/tmp/install/docs
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/my-project/farming-guidance-system-src/main.o -c -Wall -Wextra
-fPIC -ggdb3
-D'INSTALL_LIB_DIR="/home/matias/Proyectos/my-project/install/libs"'
--std=c++0x -Wno-sign-compare -DDEBUG -DQT_CORE_LIB -DQT_GUI_LIB
-DQT_SHARED -Ibuild/my-project/farming-guidance-system-src
-Ibuild/my-project/farming-guidance-system-src/uiDirector
-Ibuild/my-project/src/common -Iinstall/includes
-Iinstall/includes/my-object build/my-project/src/main.cpp
build/my-project/src/main.cpp:2:30: *fatal error: QtGui/QApplication: No
such file or directory*
*compilation terminated.*
scons: *** [build/my-project/src/main.o] Error 1
scons: building terminated because of errors.

As you can see. It seems like the tools is being loaded properly but some
further path setting is necessary, because it's not adding the qt include
directory in the g++ statement.

In the job we are using a series of extensions to scons (fbuild,
code.google.com/p/fudepan-build/source/). Which features integration with
the aforementioned tool and does a little bit of path setting
https://code.google.com/p/fudepan-build/source/browse/site_scons/extension_qt.py
.
With those settings. The project "builds", but can't resolve the paths to
the resources pointed in my qrc's:

RCC: Error in 'build/my-project/src/uiDirector/images.qrc': Cannot find
file 'res/images/red_arrow.png'

Unless I set the absolute path to the image.
In that case... I have this series of problems:

build/my-project/src/main.o: In function `~QTDisplayCoordinator':
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/uiDirector/qtDisplayCoordinator.h:32:
undefined reference to `vtable for NSUIDirector::QTDisplayCoordinator'
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/uiDirector/qtDisplayCoordinator.h:32:
undefined reference to `vtable for NSUIDirector::QTDisplayCoordinator'
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/uiDirector/qtDisplayCoordinator.h:32:
undefined reference to `vtable for NSUIDirector::QTDisplayCoordinator'
build/my-project/src/uiDirector/src/deviationAreaWidget.o: In function
`DeviationAreaWidget':
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/src/deviationAreaWidget.cpp:33:
undefined reference to `vtable for NSUIDirector::DeviationAreaWidget'
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/src/deviationAreaWidget.cpp:33:
undefined reference to `vtable for NSUIDirector::DeviationAreaWidget'
build/my-project/src/uiDirector/src/qtDisplayCoordinator.o: In function
`QTDisplayCoordinator':
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/src/qtDisplayCoordinator.cpp:28:
undefined reference to `vtable for NSUIDirector::QTDisplayCoordinator'
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/src/qtDisplayCoordinator.cpp:28:
undefined reference to `vtable for NSUIDirector::QTDisplayCoordinator'
/home/matias/Proyectos/fudepan-build/build/my-project/src/uiDirector/src/qtDisplayCoordinator.cpp:28:
undefined reference to `vtable for NSUIDirector::QTDisplayCoordinator'
collect2: ld returned 1 exit status
scons: *** [build/fgs-app/bin/fgs-app] Error 1
scons: building terminated because of errors.

Which look like the MOC is missing the some information from my headers.
This one is solved if I put my *.h* files next to my *.cpp* files, which,
for coding guidelines I tend to avoid.

So, summing up:

- How would be the proper way to set the evironment for the qt_tool?
- How can I tell scons where my resources are so it solve the paths and I
don't have to hardcode absolute paths on my .qrc's.
- What is the proper setup for MOC to resolve my includes correctly?

Sorry this ended up as a wall of text. I can split it in smaller question
if you guys want, as the problems were somewhat related I thought it was
better to post them togheter.

Thanks in advance.


--
<http://www.tallertechnologies.com>
Matías Iturburu
Software Engineer

*San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina

*
*Phone: +54 351 4217888 / +54 351 4218211
Skype: matias.iturburu*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20131007/274af885/attachment.htm


More information about the Scons-users mailing list