Including taglib in Qt project



  • Hi everyone ... I have some problems with including taglib into my qt project ... I have built taglib sources , so now i have libtag.a and libtag_c.a files .

    MAIN.CPP :

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

    using namespace std;

    ...

    TagLib::FileRef f("Help!.mp3",true);
    

    ...

    PRO-FILE:
    ...

    LIBS += C:\Users\gagoq\Documents\Libraries\taglib\lib\libtag.a
    INCLUDEPATH += C:\Users\gagoq\Documents\Libraries\taglib\include\taglib

    COMPILE OUTPUT:

    18:44:32: Running steps for project untitled1...
    18:44:32: Configuration unchanged, skipping qmake step.
    18:44:32: Starting: "C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe"
    C:/Qt/Tools/mingw492_32/bin/mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory 'C:/Users/gagoq/Documents/build-untitled1-Desktop_Qt_5_6_0_MinGW_32bit-Debug'
    g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\untitled1 -I. -I..\Libraries\taglib\include\taglib -I........\Qt\5.6\mingw49_32\include -I........\Qt\5.6\mingw49_32\include\QtWidgets -I........\Qt\5.6\mingw49_32\include\QtGui -I........\Qt\5.6\mingw49_32\include\QtANGLE -I........\Qt\5.6\mingw49_32\include\QtCore -Idebug -I. -I........\Qt\5.6\mingw49_32\mkspecs\win32-g++ -o debug\main.o ..\untitled1\main.cpp
    g++ -Wl,-subsystem,windows -mthreads -o debug\untitled1.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -lmingw32 -LC:\Qt\5.6\mingw49_32\lib C:\Qt\5.6\mingw49_32\lib\libqtmaind.a -LC:\utils\postgresql\pgsql\lib -LC:\utils\my_sql\my_sql\lib -lshell32 C:\Users\gagoq\Documents\Libraries\taglib\lib\libtag.a C:\Qt\5.6\mingw49_32\lib\libQt5Widgetsd.a C:\Qt\5.6\mingw49_32\lib\libQt5Guid.a C:\Qt\5.6\mingw49_32\lib\libQt5Cored.a
    debug/main.o: In function Z5qMainiPPc': C:\Users\gagoq\Documents\build-untitled1-Desktop_Qt_5_6_0_MinGW_32bit-Debug/../untitled1/main.cpp:18: undefined reference to_imp___ZN6TagLib8FileNameC1EPKc'
    C:\Users\gagoq\Documents\build-untitled1-Desktop_Qt_5_6_0_MinGW_32bit-Debug/../untitled1/main.cpp:18: undefined reference to _imp___ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE' Makefile.Debug:65: recipe for target 'debug\untitled1.exe' failed C:\Users\gagoq\Documents\build-untitled1-Desktop_Qt_5_6_0_MinGW_32bit-Debug/../untitled1/main.cpp:18: undefined reference to_imp___ZN6TagLib7FileRefD1Ev'
    mingw32-make[1]: Leaving directory 'C:/Users/gagoq/Documents/build-untitled1-Desktop_Qt_5_6_0_MinGW_32bit-Debug'
    makefile:34: recipe for target 'debug' failed
    C:\Users\gagoq\Documents\build-untitled1-Desktop_Qt_5_6_0_MinGW_32bit-Debug/../untitled1/main.cpp:18: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[1]: *** [debug\untitled1.exe] Error 1
    mingw32-make: *** [debug] Error 2
    18:44:41: The process "C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2.
    Error while building/deploying project untitled1 (kit: Desktop Qt 5.6.0 MinGW 32bit)
    When executing step "Make"
    18:44:41: Elapsed time: 00:10.

    so, what am i doing wrong ?


  • Qt Champions 2017

    @Gagiopapinni
    Hello!

    LIBS += -LC:/Users/gagoq/Documents/Libraries/taglib/lib -ltag
    INCLUDEPATH += C:/Users/gagoq/Documents/Libraries/taglib/include/taglib
    PRE_TARGETDEPS += C:/Users/gagoq/Documents/Libraries/taglib/lib/libtag.a
    

    Also make sure you use the same compiler for building the static library and your application. As a side note I advise to always use forward slashes giving paths even on Windows and I personally prefer the *nix style linking switches.

    I hope that helps.
    Kind regards.



  • @kshegunov without results ... it is the same compiler (MinGW 32bit)


  • Qt Champions 2017

    @Gagiopapinni
    Okay, can you verify that this symbol is present in the static lib? (you could use "dependency walker" for that purpose)