Qt - 如何编译特定的插件/组件
我正在使用 Qt 4.7.2。我做了一个需要 mp3 支持的项目。所以我给它添加了声子支持。当我静态编译它时,它显示了一些链接错误,如下所示,
Element.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public:
class Phonon::MediaSource __thiscall Phonon::MediaObject::currentSource(void)const "
(__imp_?currentSource@MediaObject@Phonon@@QBE?AVMediaSource@2@XZ) referenced in function
"public: void __thiscall Element::save(void)" (?save@Element@@QAEXXZ)
MainWindow.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
public: class Phonon::MediaSource __thiscall
Phonon::MediaObject::currentSource(void)const " (__imp_?
currentSource@MediaObject@Phonon@@QBE?AVMediaSource@2@XZ)
我在编译库时没有给出 -no-phonon 选项。但我怀疑默认情况下声子不会被静态编译。有没有办法以静态方式单独编译声子,并在我的项目中链接该库(或复制粘贴该 dll)?
编辑: 可能是迟来的编辑。我把项目文件留在某处。我必须在空闲时间挖掘它们。但是,这可能会对其他人有所帮助。这是来自“Lukasz Czerwinski”所述的链接。我想这就是原因。
General rule #4: Phonon can't be compiled statically into your application and in
general Phonon will not work for statically built apps. Link your Phonon-based app
dynamically."
I am using Qt 4.7.2. I made one project which requires mp3 support. So I added the phonon support to it . When I compiled it statically It showed some linking errors like the below
Element.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public:
class Phonon::MediaSource __thiscall Phonon::MediaObject::currentSource(void)const "
(__imp_?currentSource@MediaObject@Phonon@@QBE?AVMediaSource@2@XZ) referenced in function
"public: void __thiscall Element::save(void)" (?save@Element@@QAEXXZ)
MainWindow.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
public: class Phonon::MediaSource __thiscall
Phonon::MediaObject::currentSource(void)const " (__imp_?
currentSource@MediaObject@Phonon@@QBE?AVMediaSource@2@XZ)
I didn't give -no-phonon option when I compiled the library. But I suspect that phonon won't be compiled statically by default. Is there any way to compile phonon alone in static manner, and link that library(or copy paste that dll) in my project?
EDIT:
May be a belated edit. I left the project files somewhere. I have to dig them in my free time. But, it may help the others . This is from the link stated by 'Lukasz Czerwinski'. I think this is the reason.
General rule #4: Phonon can't be compiled statically into your application and in
general Phonon will not work for statically built apps. Link your Phonon-based app
dynamically."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说添加:
LIBS += -lphonon
到 .pro 文件工作正常。如果这没有帮助,请查看:http://www.qtcentre .org/wiki/index.php?title=How_to_get_Phonon_working 并检查您是否拥有其中所述的所有文件。
For me adding:
LIBS += -lphonon
to .pro file worked fine.If this didn't help, take a look at: http://www.qtcentre.org/wiki/index.php?title=How_to_get_Phonon_working and check that you have all files that are stated there.