Qt Sound problem

Hello again,

I'm now working with Qt to develop GUI application. My current project is a cross-platform timer application.

The GUI prompts the user to set hours, minutes and seconds when the timer will time out - working.
The application should timeout after a few seconds (hours*3600 + minutes*60 + seconds) - working.
The application opens a message box with time out message - working.
At the same time it should play a sound file - not working.

I did it exactly the same way as in the Qt documentation, included <QSound> and added QT += multimedia to the project.

Code:
QSound::play(":/music/beep.wav");

Error:
mainwindow.obj:-1: Fehler: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: static void __cdecl QSound::play(class QString const &)" (__imp_?play@QSound@@SAXABVQString@@@Z)" in Funktion ""private: void __thiscall MainWindow::on_run_clicked(void)" (?on_run_clicked@MainWindow@@AAEXXZ)".

in English:
mainwindow.obj:-1: Error: LNK2019: Reference to unsolved external symbol ""__declspec(dllimport) public: static void __cdecl QSound::play(class QString const &)" (__imp_?play@QSound@@SAXABVQString@@@Z)" in function ""private: void __thiscall MainWindow::on_run_clicked(void)" (?on_run_clicked@MainWindow@@AAEXXZ)".

Do you know a answer or is it better to seek assistance in Qt forum?

Thanks for your answers in advance.

Florian
Unresolved external symbol means the linker can't find the compiled function you've asked for; it looked through the libraries you told it to, and didn't find it.

This would indicate that however you're meant to indicate which libraries to look in (I presume adding QT += multimedia to the project file) isn't working.
Thanks for your answer.

I understand what you mean, but as I told, I used the same instruction from Qt documentation and copied it directly to the project file to avoid typo.

If nobody else knows a solution, I'll better ask in Qt forum.
Can you see the build command? Does the build command give the instruction to link against the right library?

After you fiddle with the Qt project file, you need to run qmake or some such to make it generate the right makefile so that the makefile links against the right library.
Command:
C:\Qt5\Tools\QtCreator\bin\jom.exe -f Makefile.Release
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\Timer -I. -IC:\Qt5\5.9.1\msvc2015\include -IC:\Qt5\5.9.1\msvc2015\include\QtWidgets -IC:\Qt5\5.9.1\msvc2015\include\QtGui -IC:\Qt5\5.9.1\msvc2015\include\QtANGLE -IC:\Qt5\5.9.1\msvc2015\include\QtCore -Irelease -I. -IC:\Qt5\5.9.1\msvc2015\mkspecs\win32-msvc -Forelease\ @C:\Users\FLORIA~1.FLO\AppData\Local\Temp\mainwindow.obj.9412.31.jom
mainwindow.cpp

I'll try to run qmake.
Executing qmake helped to build the EXE, but QSound doesn't play the sound from the resource file.
Not thinking you are to stupid to find a correct answer, maybe it would be best to ask at Qt support.
Thanks for your Help!

Edit: it helped to "rebuild" the wave file. It was corrupt, so QSound was unable to play it.
Last edited on
Topic archived. No new replies allowed.