使用 scons-qt4 插件时如何链接第三方库?
我正在使用 scons-qt 插件来构建并与 Qt 链接。我必须构建一组链接到我自己的库的可执行文件。此外,库还必须链接到 Qt 之外的一些第三方库。因此,在库的 SConscript 中我写道:
env.SharedLibrary ('proverim', Glob ('*.cc'), LIBS = Split ('sane quazip'))
对于可执行文件:
env.Program ('PCorrect', Glob ('*.cc'), LIBS = ['proverim'])
但是我收到了很多链接错误 - 显然这会禁用 scons-qt 插件通常生成的所有 -lQtCore -lQtGui 等开关。如果我从该 SharedLibrary 行中删除 LIBS 并将所有链接放入可执行文件中,例如:
env.Program ('PCorrect', Glob ('*.cc'), LIBS = Split ('proverim sane quazip'))
一切正常 - libproverim 与 Qt 链接,PCorrect 与 libproverim 链接以及第三方库。但我有一种感觉,一定有一个正确的方法可以做到这一点。另外,如果我不需要建立一个单独的库我该怎么办?那么,在使用 scons-qt 插件时如何添加其他库进行链接?
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', Glob ('*.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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您看到的行为是预期的。通过写入
或
完全覆盖可能已由 qt4.py 在 EnableQt4Modules() 方法中设置的 LIBS。
相反,您想要做的是将您的库添加到 Qt4 中。为此,请使用 Append() 方法:
最后,我想提一下,这是 SCons 中的基本功能(请查看手册页和手册以获取更多信息),与 Qt4 工具没有直接关系...;)
The behaviour you see is expected. By writing
or
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:
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... ;)