To read ID3 tags from MP3 files using C++ and Qt you can take many routes and here are some of them:
- You can read the Wikipedia article on ID3 Tags (which is pretty much detailed) and write your own ID3 Tag reader. Simple but takes too long.
- Or you can use some kind of 3rd party library, like id3lib which encapsulates all the complexities. This is even more simple and doesn’t take that much time 🙂
Here is a simple guide on how to use id3lib with Qt:
- Download id3lib binaries and source codes from here.
- Copy include folder and binaries to your project folder.
- Add the include path and libs to your PRO file.
- INCLUDEPATH += id3lib/include
- id3lib/bin/Release/id3lib
- Add the following line to the topmost point of your sources, or in other words, before including id3 sources.
- #define ID3LIB_LINKOPTION 3
- Include id3lib main header in your source.
- #include “id3.h”
- Before you try to run the project make sure that id3lib DLL file is copied to the same folder with your project’s executable.
You can download the example Qt project from here:
Hi! Example project doesn’t work (qt vers. 5.12.4) mingw 7.3.0 x64, windows 7 x64
I have 392 issues, the first two errors telling:
…\id3lib\include\id3\globals.h:72: error: ‘dllimport’ was not declared in this scope
# define ID3_C_EXPORT extern _declspec(dllimport)
You need to read a bit more about using libraries in C++.
Here is a link that might help:
https://docs.microsoft.com/en-us/cpp/cpp/using-dllimport-and-dllexport-in-cpp-classes