Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QSound and error 2019
Forum Updated to NodeBB v4.3 + New Features

[Solved] QSound and error 2019

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 9.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    patouf35
    wrote on last edited by
    #1

    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:
    @#include "mainwindow.h"
    #include <QApplication>
    /#include <QtMultimedia/QMediaContent>
    #include <QtMultimedia/QMediaPlayer>
    #include <QUrl>
    /
    #include <QtMultimedia/QSound>
    int main(int argc, char argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    /
    QMediaContent media(QUrl::fromLocalFile("pan.wav"));
    QMediaPlayer player;
    player.setMedia(media);
    player.play();*/
    QSound::play("pan.wav");

    return a.exec&#40;&#41;;
    

    }@

    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 :)

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • P Offline
        P Offline
        patouf35
        wrote on last edited by
        #3

        I am using QT5

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          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?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • P Offline
            P Offline
            patouf35
            wrote on last edited by
            #5

            Thanks for the answer, unfortunately I tried it but I still have the same issue.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              You need to post the .pro and the linker output then.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • P Offline
                P Offline
                patouf35
                wrote on last edited by
                #7

                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
                mainwindow.cpp

                HEADERS += mainwindow.h

                FORMS += mainwindow.ui
                @
                and here is the output:

                \Users\leo\AppData\Local\Temp\Melody_gen.exe.1108.1841.jom
                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'

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vezprog
                  wrote on last edited by
                  #8

                  Try giving the QSound static call the full path of the .wav file, file system and all..

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    patouf35
                    wrote on last edited by
                    #9

                    you mean trying this?
                    @ QSound::play("C:/Users/leo/documents/c++/melody-gen/pan.wav");@
                    Because When I try this I still get the same error...

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      [quote author="patouf35" date="1358908620"]you mean trying this?
                      @ QSound::play("C:/Users/leo/documents/c++/melody-gen/pan.wav");@
                      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.

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        patouf35
                        wrote on last edited by
                        #11

                        Thanks a lot! When I ran qmake it worked. Thanks again! :)

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          koahnig
                          wrote on last edited by
                          #12

                          You are welcome ;-)

                          Vote the answer(s) that helped you to solve your issue(s)

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved