Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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 http://pastebin.com/3EH16jrw
    and I copied the sourcecode from https://github.com/metabrainz/libmusicbrainz/blob/master/examples/cdlookup.cc
    I commented everything out except one line http://pastebin.com/C3q3SsU0
    Output is http://pastebin.com/uV547kxq

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

    Thanks!
    Proton



  • 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 libmusicbrainz5.so 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 libmusicbrainz5.so in one of the directories stated in your pro file?



  • @jsulm I'm still not quite sure what you mean. libmusicbrainz5.so 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 libmusicbrainz5cc.so library. I used that instead and know my project compiles. Sorry for wasting your time and thanks again for your help!

    Best regards
    Proton


Log in to reply