I'm using scons-qt plugin to build and link with Qt. I have to build a set of executables that link to my own library. Also, library has to link to some third-party libraries beside Qt. So, in library's SConscript I write:
env.SharedLibrary ('proverim', Glo开发者_Python百科b ('*.cc'), LIBS = Split ('sane quazip'))
And for an executable:
env.Program ('PCorrect', Glob ('*.cc'), LIBS = ['proverim'])
But I'm getting a lot of linking errors - apparently this disables all the -lQtCore -lQtGui etc switches scons-qt plugin normally generates. If I remove LIBS from that SharedLibrary line and put all the linking into the executable, like:
env.Program ('PCorrect', Glob ('*.cc'), LIBS = Split ('proverim sane quazip'))
Everything works fine - libproverim links with Qt and PCorrect links with libproverim, as well as with third-party libraries. But I got a feeling there must be a right way to do it. Besides, what would I do if I didn't need to make a separate library? So, how do you add other libraries for linking when working with scons-qt plugin?
The behaviour you see is expected. By writing
env.Program ('PCorrect', Glob ('*.cc'), LIBS = ['proverim'])
or
env['LIBS'] = ['proverim']
you completely overwrite the LIBS that may have been set by qt4.py in the EnableQt4Modules() method.
What you want to do instead is adding your libraries to the Qt4 stuff. Please use the Append() method for this:
env.Append(LIBS=['proverim'])
env.Program('PCorrect', Glob('*.cc'))
Finally, I would like to mention that this a basic functionality in SCons (please check the Man page and manual for more info) and not directly related to the Qt4 Tool... ;)
精彩评论