Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to `QSound::play(QString const&)'

Tags:

ubuntu

qt

audio

qt5

Trying to play sound, via QSound (QT 5, Ubuntu 13.04)

The code:

#include <QtMultimedia/QSound>
void MainWindow::on_pushButton_2_clicked()
{
QSound::play("sounds/win.wav");
}

And getting 2 errors: undefined reference to `QSound::play(QString const&)' collect2: error: ld returned 1 exit status

What am i doing wrong ? In documentation here i see the same code.

like image 592
user1665530 Avatar asked Jan 22 '26 06:01

user1665530


1 Answers

You need to include the multimedia module. Add this to your .pro file:

QT += multimedia

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!