Communication error with taglib on Windows

I built static libraries for taglib for windows as follows. Gotto use mingw, not VS.

  • Check out git clone https://github.com/taglib/taglib.git git_taglib
  • Installed cmake with the Win32 installer from cmake.org
  • Configure cmake -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
  • Compile mingw32-make.exe
  • Install mingw32-make.exe install in C:\taglib_package

In my Qt project, I use this library, for example,

.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 results in the 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 guess the culprit is lib. How do I compile a library to fix the above linking error?

+5
source share
1 answer

Use the -DTAGLIB_STATIC command when compiling code

+2
source

Source: https://habr.com/ru/post/1206723/


All Articles