Important: Please read the Qt Code of Conduct -

"undefined reference to"-problem I'm not able to solve

  • Hi!
    Thanks in advance to everybody willing to help and reading this.
    I'm willing to search and read but I'm totally stuck.

    I want to write a little program that runs on Linux, Windows and hopefully on Android some day.
    This program should use some libraries e.g. musicbrainz.

    I compiled musicbrainz, installed it and added it to my project with qt-creator.
    The .pro-file looks like this
    and I copied the sourcecode from
    I commented everything out except one line
    Output is

    I have no clue why this is and I really need some help.


  • You are likely not including all the files you are using in your pro file. For example, one of the include lines in your program looks like this:

    #include "musicbrainz5/Query.h"

    but I don't see any reference to 'Query.cpp' in your PRO file. This is likely where the link error is coming from (?).

    I don't know what musicbrainz is all about but there might be a 'PRI' file which will have a list of all the sources related to this software that needs to be added. You add a line to your PRO file to include the PRI file.

  • Qt Champions 2019

    @Rondog He is linking against musicbrainz5 lib, so no need to add musicbrainz5 sources to the project.
    @Proton Is the located in one of the lib directories you pass to the linker?
    "g++ -m64 -o Worker4Music main.o mainwindow.o mainworker.o musicbrain.o moc_mainwindow.o moc_mainworker.o -L/usr/X11R6/lib64 -L/home/proton/Dev/Worker4Music/../../../../usr/local/lib/ -ltag -lmusicbrainz5 -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread"

  • First of all, thanks for your help!

    @Rondog: jsulm is write, I'm linking against musicbrainz library.

    @jsulm: I don't really know what you mean. Path to musicbrainz lib is usr/local/lib/ and path to the project is /home/proton/Dev/Worker4Music/
    Should I copy the library to a directory of the project?

    Best regards

  • Qt Champions 2019

    @Proton I mean is the file in one of the directories stated in your pro file?

  • @jsulm I'm still not quite sure what you mean. is in the directory /usr/local/lib/ and if PWD is /home/proton/Dev/Worker4Music/ than "LIBS += -L$$PWD/../../../../usr/local/lib/ -lmusicbrainz5" states this directory, doesn't it?

  • I finally found my mistake. I wanted to copy the library to a directory in the build tree and than I saw there is also a library. I used that instead and know my project compiles. Sorry for wasting your time and thanks again for your help!

    Best regards

Log in to reply