Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

error: undefined reference to `snd_device_name_hint'



  • In my project I added a class. In its .h file I started typing:

    #include <alsa/asoundlib.h>
    

    When I typed al, QtCreator allowed me to pick alsa/
    When I typed asou, it allowed me to pick asoundlib.h.
    This leads me to believe that alsa development library is installed and visible to QtCreator.
    Next, I start typing code in the body of the class.

        name = snd_device_name_get_hint(*n, "NAME");
    

    When I type snd_device, it allows me to pick the function above from the list of three similar functions. This leads me to believe that the included ALSA API is visible to QtCreator.

    When I Ctrl-click on the function name, QtCreator opens ALSA's control.h where it is declared.
    So far it is all nice and dandy.

    But when I build the project, after running qmake, of course, it throws the error in the subject.
    So which tool still does not know that the proper .h files are included?


  • Lifetime Qt Champion

    You also need to link against the alsa libs I would guess.



  • Thank you!

    For posterity, this means opening .pro file in editor, right-clicking empty space, and selecting "Add library", then browsing to /lib64 and selecting libasound.so, which after un-checking Windows and Mac platforms then adds the following line to the .pro file:

    unix:!macx: LIBS += -lasound
    

    Then run qmake and build.


  • Lifetime Qt Champion

    @In-Fo Please mark this topic as solved then, thx.


Log in to reply