Taglib Library
-
Hi all,
I try to link taglib to my project but when I build it, I got errors as this photoThis is my .pro file:
In header files, I included all necessary files like this
I don't know what problems I'm facing with :'(
Hope you guys help me deal with it. Thank you so much -
@lucas_1603
what compiler are you using?
anyway you never link against DLL file. And there should also be a corresponding warning in the build console
LIBS += -L$$PWD/taglib -ltag
orLIBS += -L$$PWD/taglib -llibtag
(depnding how the lib file is called)
taglib should also provide a .lib/.a file? -
@raven-worx
I'm using MinGW compiler. Taglib provides a .dll and a .a file -
@lucas_1603 Did you build the lib by yourself?
If you downloaded it: from where and which compiler was used to build it? -
@jsulm I downloaded taglib from taglib.org and used cmake to build it. After successfully built, I got a .dll and a .dll.a file. What I have to do next to link taglib to my project? I'm new in Qt so guide me step-by-step, please.
Thanks a lot -
@lucas_1603 There should be a .lib file as well as @raven-worx said.
Also, the way you use LIBS in pro file is wrong: remove .dll from file name (again, like @raven-worx suggested). When adding libs using -l the "lib" prefix and file extension (.lib, .so, ...) must be removed. Example: if lib is called libfoo.lib you add "-lfoo" to your pro file. -
@jsulm I actually cannot find any .lib files. I built taglib following the guidelines of this tutorial. After building process completed, it just generated 2 files more, one is .dll and the other is .dll.a as I said before. I don't know whether I built taglib right or wrong, or there were something I don't well aware of :((
-
@lucas_1603 Then fix LIBS in your pro file as described before and try again.
-
@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.
-
@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? -
@lucas_1603 I'm not a Windows expert, but I think you really need .lib file on Windows at build time, not .dll
-
Hi,
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.
-
@lucas_1603
renametaglib.dll.a
totaglib.a
Also read this