I built taglib
static libraries for Windows as follows. Gotto use mingw, not VS.
git clone https://github.com/taglib/taglib.git git_taglib
cmake
with Win32 installer from cmake.orgcmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=/C/taglib_package -DCMAKE_C_COMPILER=/C/MinGW4.4/bin/gcc.exe -DCMAKE_CXX_COMPILER=/C/MinGW4.4/bin/g++.exe -DENABLE_STATIC=ON -DENABLE_STATIC_RUNTIME=ON -DHAVE_ZLIB=0
mingw32-make.exe
mingw32-make.exe install
to C:\taglib_package
In my Qt project, I am using this library like thus
.pro
INCLUDEPATH+="C:/taglib_package/include/taglib"
QMAKE_LIBDIR += "C:/taglib_package/lib"
LIBS+= -lz -ltag
.cpp
#include "fileref.h"
#include "taglib.h"
...
TagLib::FileRef f("Z:/Documents/sample.mp3");
TagLib::String artist = f.tag()->artist();
std::cout<< "Artist is " << artist << std::endl;
This leads to following link error
release/main.o:main.cpp:(.text+0x93): undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
release/main.o:main.cpp:(.text+0xb3): undefined reference to `_imp___ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE'
release/main.o:main.cpp:(.text+0xdf): undefined reference to `_imp___ZNK6TagLib7FileRef3tagEv'
release/main.o:main.cpp:(.text+0x101): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
release/main.o:main.cpp:(.text+0x10a): undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
release/main.o:main.cpp:(.text+0x210): undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
release/main.o:main.cpp:(.text+0x2bd): undefined reference to `_imp___ZN6TagLib6StringD1Ev'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\taglib_experiment.exe] Error 1
mingw32-make: *** [release] Error 2
19:56:21: The process "C:\MinGW4.4\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project taglib_experiment (kit: Desktop)
When executing step 'Make'
The code works fine on a Mac. So I suppose the culprit is the lib. How should I compile the library to solve the above linking error?
Use the -DTAGLIB_STATIC
switch when compiling your code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With