Important: Please read the Qt Code of Conduct -

How to use TagLib into my Qt c++ Project

  • Hello,

    I'd like to get the additional information of a media file in a qt application i'm building and so i decided to use taglib. Can anyone tell me how to use TagLib in qt from the beginning ? The version I got was 1.6.3.


  • Lifetime Qt Champion


    If you mean add that library to your Qt project, you can follow that guide for Qt Creator.

  • @Moderators @mrjj @Qt-Champions-2015 @Lifetime-Qt-Champion
    I have no idea what to do with it or add which file to my app. can you please explain how to build it?
    What I did so far:
    (Currently working on mac but want it for both Windows and mac).

    1. Download TagLib-1.6.3.

    Now using terminal:
    cd /Taglib-1.6.3
    sudo make install

    A default build and install. So, the configure prefix was /usr/local. But there is no .a file in my lib folder. Please guide me with necessary steps to build and use Taglib in my qt Project.

    Here is the Snapshot:
    Thanks @SGaist

  • After searching, I found a solution.

    $ cd taglib-1.6.3

    $ cmake -DCMAKE_BUILD_TYPE=Release

    $ make

    $ sudo make install

    Now I have "libtag.a" inside my lib folder (/Users/macwaves/Desktop/lib2/lib) and about 75 header files inside "/Users/macwaves/Desktop/lib2/include/taglib".

    I have created a project and then open .pro file, right click ( just in middle of file)
    and choose "Add library", then browse to the .a file.

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../Users/macwaves/Desktop/lib2/lib/release/ -ltag
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../Users/macwaves/Desktop/lib2/lib/debug/ -ltag
    else:unix: LIBS += -L$$PWD/../../../../Users/macwaves/Desktop/lib2/lib/ -ltag
    INCLUDEPATH += $$PWD/../../../../Users/macwaves/Desktop/lib2/include/taglib
    DEPENDPATH += $$PWD/../../../../Users/macwaves/Desktop/lib2/include/taglib
    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../Users/macwaves/Desktop/lib2/lib/release/libtag.a
    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../Users/macwaves/Desktop/lib2/lib/debug/libtag.a
    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../Users/macwaves/Desktop/lib2/lib/release/tag.lib
    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../Users/macwaves/Desktop/lib2/lib/debug/tag.lib
    else:unix: PRE_TARGETDEPS += $$PWD/../../../../Users/macwaves/Desktop/lib2/lib/libtag.a

    Now In my mainwindow.h

    #include <QMainWindow>
    #include <fileref.h>
    #include <tag.h>

    and mainwindow.cpp

    TagLib::FileRef f("/Users/macwaves/Desktop/Testing/my.mp3",true);

    but it's generating errors.
    :-1: error: symbol(s) not found for architecture x86_64
    :-2: error: linker command failed with exit code 1 (use -v to see invocation)

    Please help me ! Thanks

  • Lifetime Qt Champion

    Since your on Linux, why not install the taglib devel package from your distribution ?

Log in to reply