Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
@lucas_1603 Then fix LIBS in your pro file as described before and try again.
@jsulm I tried to fix it to LIBS += -L$$PWD/taglib -ltag as you suggested but it raised "cannot find -ltag" error!
@lucas_1603 What is the exact file name of the lib?
Also, $$PWD/taglib is a relative path - are you sure it is correct (you can check the linker output to see what exactly is passed to -L.
@jsulm I would like to describe more details for you to understand my problems clearly
This is exactly what I have tried :
After downloading taglib (version 1.11.1) from taglib.org, I built it with cmake and got a .dll and a .dll.a file. Then I brought taglib folder to where my Qt project folder is in and named it 'myTaglib' as this picture
When I go to 'myTaglib' folder, I'll get these items
Now jumping into .pro file, I tried to link to taglib:
QT += quick multimedia core CONFIG += c++11 INCLUDEPATH += $$PWD/myTaglib DEPENDPATH += $$PWD/myTaglib LIBS += -L$$PWD/myTaglib -ltag
And in header file, I included necessary files and using namespace TagLib like this:
#include <tag.h> #include <fileref.h> #include <mpeg/id3v2/id3v2tag.h> #include <mpeg/mpegfile.h> #include <mpeg/id3v2/id3v2frame.h> #include <mpeg/id3v2/id3v2header.h> #include <mpeg/id3v2/frames/attachedpictureframe.h> using namespace TagLib;
After all, I built my project and got some errors:
... undefined reference to `__imp__ZN6TagLib8FileNameC1EPKc' in player.cpp - line 94 undefined reference to `__imp__ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE' in player.cpp - line 94 undefined reference to `__imp__ZNK6TagLib7FileRef3tagEv' in player.cpp - line 95 undefined reference to `__imp__ZNK6TagLib6String10toCWStringEv' in player.cpp - line 97 undefined reference to `__imp__ZNK6TagLib6String10toCWStringEv' in player.cpp - line 96 ...
Then, I checked these lines but it didn't show something like underlined error or red text or something like that, you can see this picture
@lucas_1603 Can you show the linker call? Either it can't find the lib or the lib is not compatible.
@jsulm You mean this one (sorry if I misunderstood what you mean):
@lucas_1603 Yes, your taglib is not compatible with the compiler you're using.
Do you really use exact same compiler you used to compile taglib?
@jsulm I built taglib with MinGW and in this project I think it also built with MinGW
@lucas_1603 I'm not a Windows expert, but I think you really need .lib file on Windows at build time, not .dll
@jsulm Yes, I'll try to find it out. Anw, thank you so much for your time, you helped me a lot
One other thing that you can try is to link directly to the static .a library. Use the full path to that file using $$PWD.
@sgaist I tried this:
LIBS += -L$$PWD/myTaglib -llibtag.dll.a
But the linker said "cannot find -llibtag.dll.a"
As already suggested, try with
LIBS += -l$$PWD/myTagLib/libtag.dll.a
After rename, I got these:
And in .pro file, I wrote:
INCLUDEPATH += $$PWD/myTaglib DEPENDPATH += $$PWD/myTaglib LIBS += -L$$PWD/myTaglib -ltag
But I still got some errors:
But I still got some errors:
your problem is not that it can't find the lib but that it finds it already and says it is incompatible.
So you need to change the compiler in either of your 2 compilations.
I tried it out but it still didn't work, here is what I got:
I don't know why libtag.dll.a was in the same folder as my project (Drive E) but it said "cannot find..."
cd $TAGLIB mkdir build cd build cmake -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER=g++.exe -D CMAKE_MAKE_PROGRAM=mingw32-make.exe -DBUILD_SHARED_LIBS=ON -DENABLE_STATIC_RUNTIME=OFF ..
And here is the compiler of my project:
@lucas_1603 Come on, your lib is called libtag.a not libtag.dll.a, so please change it to
LIBS += -l$$PWD/myTagLib/libtag.a
Even though I had
myTaglibfolder but the linker said "cannot find..."