include id3lib in QT project, C++

1.2k Views Asked by At

==================================

Configuration :

  • Qt Creator 2.8.1
  • Qt 5.1.1
  • Windows 7 64 bits

==================================

How can I include id3lib library ?

I've already donwloaded required files (.h, .dll, .lib and .exp) from http://sourceforge.net/projects/id3lib/files/

I've already included all .h file in my project :

HEADERS  += audioTest.h \
    id3.h \
    id3/writers.h \
    id3/writer.h \
    id3/utils.h \
    id3/tag.h \
    id3/sized_types.h \
    id3/readers.h \
    id3/reader.h \
    id3/misc_support.h \
    id3/io_strings.h \
    id3/io_helpers.h \
    id3/io_decorators.h \
    id3/id3lib_strings.h \
    id3/id3lib_streams.h \
    id3/id3lib_frame.h \
    id3/helpers.h \
    id3/globals.h \
    id3/field.h

Then I've included the library :

win32: LIBS += -L$$PWD/id3lib/ -lid3lib
INCLUDEPATH += $$PWD/id3lib
DEPENDPATH += $$PWD/id3lib
win32: PRE_TARGETDEPS += $$PWD/id3lib/id3lib.lib

Then, when I execute the bellow example, it tells me

  • undefined reference to ID3_Tag::ID3_Tag(char const*)'
  • undefined reference to 'ID3_Tag::~ID3_Tag()'
  • error: ld returned 1 exit status

Code :

ID3_Tag tag("a.mp3");

Something wrong with what I've done ? I know undefined reference to * means a bad library inclusion, but I can't find where I failed.

And I can't find solution on the web :

  • Here they decide to use taglib, but I read here id3lib was better.
  • Here they say LIBS += /usr/lib/libid3.a works. But not on Windows.
  • ...

Someone got an idea ?

2

There are 2 best solutions below

15
László Papp On

You have several problems ongoing...

First of all, you do not need to include 3rd party headers into your HEADERS variable. You only need to specify the location for the INCLUDEPATH if any.

Secondly, you will need to specify the library name and location for the LIBS variable as follows:

LIBS += -L/path/to/id3lib/installation -lid3libname
1
Volt On

How do you compile? I have Linux and compile with g++ -lid3 -lz. Switch -lid3 is for id3lib which needs compress as well so -lz.