Newby needs help building QMediaPlayer Example
-
Trying to make a simple code example that uses XMediaPlayer to play a couple of mp3 files.
Partial code below, followed by error codes.
The build is for Simulator Qt for MinGW 4.4 (Nokia Qt SDK) (Nokia Forum QT 4.7.0)
Any ideas for this newby lab rat developer. (I haven't used this IDE before)
@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtMultimediaKit/QMediaPlayer.h>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::playAudioFile(QString localFile)
{
QMediaPlayer *player; // line 19
player = new QMediaPlayer; // Line 20
// line 21
player->setMedia(QUrl::fromLocalFile(localFile)); // line 22
player->setVolume(50); // line 23
player->play(); // line 24
}void MainWindow::on_playButton1_clicked()
{
playAudioFile(ui->lineEdit1->text());
}void MainWindow::on_playButton2_clicked()
{
playAudioFile(ui->lineEdit2->text());
}
@
Build results in the following errors :Running build steps for project TestPlayMedia...
Configuration unchanged, skipping qmake step.
Starting: "C:/NokiaQtSDK/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'C:/NokiaQtSDK/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\TestPlayMedia.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\NokiaQtSDK\Simulator\Qt\mingw\lib" -lmingw32 -lqtmaind -LC:\NokiaQtSDK\Simulator\QtMobility\mingw\lib -lQtMobilitySimulatord1 -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib
mingw32-make[1]: Leaving directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'
mingw32-make: Leaving directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:20: undefined reference to `_imp___ZN21QMediaServiceProvider22defaultServiceProviderEv'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:20: undefined reference to `_imp___ZN12QMediaPlayerC1EP7QObject6QFlagsINS_4FlagEEP21QMediaServiceProvider'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN13QMediaContentC1ERK4QUrl'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN12QMediaPlayer8setMediaERK13QMediaContentP9QIODevice'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN13QMediaContentD1Ev'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN13QMediaContentD1Ev'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:23: undefined reference to `_imp___ZN12QMediaPlayer9setVolumeEi'
debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:24: undefined reference to `_imp___ZN12QMediaPlayer4playEv'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\TestPlayMedia.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/NokiaQtSDK/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project TestPlayMedia (target: Qt Simulator)
When executing build step 'Make'[edit: Highlighting added / Denis Kormalev]
-
Looks like a linking problem.
Did you include QtMobility and Multimediakit in your .pro file?
-
Adding mobility and multimediakit to your .pro solved the problem?