大家好,我用phonon播放音乐,其代码如下:
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <phonon/mediaobject.h>
#include <QTextCodec>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec *codec = QTextCodec::codecForName("GB2312");
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForTr(codec);
//音乐播放
Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource("E:/msc/a.mp3"));
music->play();
//视频播放
Phonon::MediaObject *movie = Phonon::createPlayer(Phonon::VideoCategory,Phonon::MediaSource("E:/Movie/lian/窃听风云.avi"));
movie->play();
return a.exec();
}
但不知为何出现以下错误:
D:\MyQT\Nokia-build-desktop\..\Nokia\main.cpp:18: 错误:undefined reference to `_imp___ZN6Phonon11MediaSourceC1ERK7QString'
D:\MyQT\Nokia-build-desktop\..\Nokia\main.cpp:18: 错误:undefined reference to `_imp___ZN6Phonon12createPlayerENS_8CategoryERKNS_11MediaSourceE'
D:\MyQT\Nokia-build-desktop\..\Nokia\main.cpp:18: 错误:undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
D:\MyQT\Nokia-build-desktop\..\Nokia\main.cpp:18: 错误:undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
D:\MyQT\Nokia-build-desktop\..\Nokia\main.cpp:19: 错误:undefined reference to `_imp___ZN6Phonon11MediaObject4playEv'
D:\MyQT\Nokia-build-desktop\..\Nokia\main.cpp:19: 错误:undefined reference to `_imp___ZN6Phonon11MediaObject4playEv'
请问原因是什么?应如何解决?
------解决方案--------------------
这个对你肯定会有帮助
http://hi.baidu.com/cyclone/blog/item/d299af511bed309f8c5430c3.html
如果你静心看的话。