How to read ID3v1 and ID3v2 tags using id3lib in Qt

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:

  1. Download id3lib binaries and source codes from here.
  2. Copy include folder and binaries to your project folder.
  3. Add the include path and libs to your PRO file.
    • INCLUDEPATH += id3lib/include
    • id3lib/bin/Release/id3lib
  4. Add the following line to the topmost point of your sources, or in other words, before including id3 sources.
    • #define ID3LIB_LINKOPTION 3
  5. Include id3lib main header in your source.
    • #include “id3.h”
  6. 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:

Download



2 Replies to “How to read ID3v1 and ID3v2 tags using id3lib in Qt”

  1. 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)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.