PDA

View Full Version : Phonon linking problem



Decessus
13th August 2010, 03:53
Hello, I seem to be having a bit of a problem using phonon as well as QSound::play();

When I try to use QSound::play();, the only sound I get is the windows error beep(ding), so I decided to use Phonon instead, even though I'm fairly certain it's a bit more resource intensive to use two instances of Phonon (one for media play back and one for environment sound effects to replace QSound). However, I am now having problems with Phonon as well.

I followed to example for Phonon included with the Qt SDK, included all that I needed for phonon, and added the QT += phonon to my project file. Still, I am having undefined reference errors when I try to compile. It doesn't seem that Phonon is being linked to my project properly, am I missing something?



debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:28: undefined reference to `_imp___ZN6Phonon11MediaSourceC1ERK7QString'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:28: undefined reference to `_imp___ZN6Phonon11MediaObject16setCurrentSourceER KNS_11MediaSourceE'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:28: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:29: undefined reference to `_imp___ZN6Phonon11MediaObject4playEv'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:28: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:34: undefined reference to `_imp___ZN6Phonon11AudioOutputC1ENS_8CategoryEP7QO bject'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:35: undefined reference to `_imp___ZN6Phonon11Me***-build-desktop/../***/***.cpp:36: undefined reference to `_imp___ZN6Phonon11MediaObject15setTickIntervalEi'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:37: undefined reference to `_imp___ZN6Phonon10createPathEPNS_9MediaNodeES1_'
debug/***.o:D:\Projects\***-build-desktop/../***/***.cpp:37: undefined reference to `_imp___ZN6Phonon4PathD1Ev'

tbscope
13th August 2010, 06:27
Did you compile Qt with Phonon support?
Or, did you install the Qt Phonon library (it might be separate on your system)

Decessus
13th August 2010, 17:14
Yes, I would assume that Phonon is installed because I am able to compile the phonon example, as well as it runs fine. Also, in my lib directory in Qt, I have libphonon.a and libphonond.a

Zlatomir
13th August 2010, 17:22
Do you have this line:

QT += phonon
in your .pro file?

Decessus
13th August 2010, 17:24
Yes sir I do

Zlatomir
13th August 2010, 17:49
I have tried to replicate that, and i can't

The only case when i get that errors, is missing QT += phonon, did you "rebuild" (run qmake again) after adding the QT += phonon? (sometimes simply clicking on the Build button <the green one> doesn't rebuild and the compiler still doesn't find the libraries, even if added)

Also check that <Phonon/MediaObject> and <Phonon/MediaSource> files are included, not only forward declared.

Decessus
13th August 2010, 17:55
Well I manually ran qmake, since rebuild did not work, and it is not trying to link the phonon libs


Running build steps for project ***...
Starting: "c:/qt/2010.04/qt/bin/qmake.exe" D:/Projects/***/***.pro -r -spec win32-g++
The process "c:/qt/2010.04/qt/bin/qmake.exe" exited normally.

This is my .pro file

QT += core gui \
phonon

TARGET = ***
TEMPLATE = app

SOURCES += main.cpp\
***.cpp

HEADERS += ***.h

FORMS += ***.ui

RESOURCES += \
images.qrc

tbscope
13th August 2010, 17:57
One thing that might be a problem is the difference in build configurations between the phonon libs and your program.

Is the Qt and Phonon library compiled with the same compiler and settings as your program?

Decessus
13th August 2010, 18:02
I never manually compiled any of the libs, I downloaded the SDK for Windows.

tbscope
13th August 2010, 18:07
Bingo :-)

Which version did you download? Visual studio version or minGW?

After finding out which you downloaded, how do you build your program. Using visual studio? or the minGW tools?

If both differ, you get these errors.

Decessus
13th August 2010, 18:10
I downloaded the minGW version as well as I use the minGW toolchain

tbscope
13th August 2010, 18:18
You downloaded the minGW toolchain separatly? If so, this might also be a problem.

Suggestion:

Remove all
Download the latest Qt SDK. This includes everything and works out of the box.

Decessus
13th August 2010, 18:23
No I did not download it seperately, I use the MinGW toolchain that comes with the SDK

Decessus
13th August 2010, 18:28
Is there a qmake flag that I can manually invoke for libphonon?

tbscope
13th August 2010, 18:39
Is there a qmake flag that I can manually invoke for libphonon?

I'm not sure what you mean, but I guess no.
You include the phonon library with QT += phonon

What you see are linker errors which means that the linker can't find certain symbols in the phonon library.
This in turn means that the library isn't found or it is compiled with another compiler (symbols are messed up).

Since neither case describes your problem, I'm out of ideas.
Can you please give more information? Describe exactly what you downloaded, every step you did between installing what you downloaded and building your program, including the full source code.

Decessus
13th August 2010, 19:08
Hmm, well I seemed to have solved my problem, which apparently was caused by manually including windows.h in an attempt to use PlaySound();

Thank you for your patience and help :)