Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] QSound and error 2019
Hi, I got a problem when I try to use the QSound or QMediaPlayer QTCreator throws a “error LNK2019: external symbol not solved”.
here’s my code:
int main(int argc, char argv)
QApplication a(argc, argv);
/ QMediaContent media(QUrl::fromLocalFile("pan.wav"));
I put “pan.wav” in each “release” and “source” folder.
When I take out all the lines that have to deal with the sound processing it all compiles fine.
I really need a little help here. Thanks :)
It is not clear to me which version you are using. For Qt 4 you need according to "this":http://qt-project.org/doc/qt-4.8/qtmultimedia.html
QT += multimedia
in your .pro file.
I am using QT5
For "Qt5 there is the same. ":http://qt-project.org/doc/qt-5.0/qtmultimedia/qtmultimedia-index.html
QT += multimedia
Do you have this line in your .pro file?
Thanks for the answer, unfortunately I tried it but I still have the same issue.
You need to post the .pro and the linker output then.
ok. here is the .pro:
Project created by QtCreator 2013-01-20T19:04:47
QT += core gui
QT += widgets
QT += multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Melody_gen
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
and here is the output:
main.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) public: static void __cdecl QSound::play(class QString const &)" (_imp?play@QSound@@SAXABVQString@@@Z) référencé dans la fonction _main
release\Melody_gen.exe : fatal error LNK1120: 1 externes non résolus
jom: C:\Users\leo\Documents\c++\Melody_gen-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release\Makefile.Release [release\Melody_gen.exe] Error 1120
jom: C:\Users\leo\Documents\c++\Melody_gen-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release\Makefile [release] Error 2
21:36:23: The process "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project Melody_gen (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK))
When executing step 'Make'
vezprog last edited by
Try giving the QSound static call the full path of the .wav file, file system and all..
you mean trying this?
Because When I try this I still get the same error...
[quote author="patouf35" date="1358908620"]you mean trying this?
Because When I try this I still get the same error...[/quote]
IMHO the path is not the problem. You have a linking problem well before you can start the application.
The linker does not find the function QSound::play. My rudimentary French is good enough to catch this.
Since the other Qt stuff is not a problem, it must have something to do with the required libs for multimedia. Unfortunately, I have no experience in multimedia nor Qt 5. I am a bit on a loss here.
Did you ever rerun qmake in creator?
When you add something in a .pro file, this file has to be converted to a makefile which will be used by jom in your case. Most likely the additions to your pro-file have not been transported to the makefile.
Under "Edit" you should have the "projects" window on the left. Right mouse click on the project name you should find in the pop-up on 3rd position something like "Run qmake". Do this and a rebuild to be sure.
Thanks a lot! When I ran qmake it worked. Thanks again! :)
You are welcome ;-)