Question

My OS is Windows 7 Ultimate x64. I'm using Qt 4.8 to write a program that will use id3lib. I've downloaded the windows binaries. Here is part of the *.pro file that shows how id3lib library is used:

HEADERS  += MainWindow.h \
    id3lib/id3/sized_types.h \
    id3lib/id3/globals.h \
    id3lib/id3/tag.h \
    id3lib/id3/utils.h \
    id3lib/id3/id3lib_frame.h \
    id3lib/id3/field.h \
    id3lib/id3/id3lib_strings.h \
    id3lib/id3/id3lib_streams.h

win32: LIBS += -L$$PWD/id3lib/ -lid3lib

INCLUDEPATH += $$PWD/id3lib
DEPENDPATH += $$PWD/id3lib

As you can guess, the library files (id3lib.dll and id3lib.lib) are in id3lib directory and all required headers are in id3lib/id3 directory.

In the globals.h, I defined the follwing:

#define ID3LIB_LINKOPTION LINKOPTION_CREATE_DYNAMIC

And modified the following section in the same file:

#    if (ID3LIB_LINKOPTION == LINKOPTION_CREATE_DYNAMIC)
       //used for creating a dynamic dll
#      define ID3_C_EXPORT extern _declspec(dllexport)
#      define ID3_CPP_EXPORT __declspec(dllexport)
#      define CCONV __stdcall // Added for VB & Delphi Compatibility - By FrogPrince Advised By Lothar
#    endif

as follows:

#    if (ID3LIB_LINKOPTION == LINKOPTION_CREATE_DYNAMIC)
       //used for creating a dynamic dll
#      define ID3_C_EXPORT Q_DECL_IMPORT
#      define ID3_CPP_EXPORT Q_DECL_IMPORT
#      define CCONV __stdcall // Added for VB & Delphi Compatibility - By FrogPrince Advised By Lothar
#    endif

so that it works with Qt.

Next, I've included id3/tag.h and written the following code:

ID3_Tag tag("test.wma");
qDebug() << tag.size();

After compilation, I got the following errors:

undefined reference to `_imp___ZN7ID3_TagC1EPKc'
undefined reference to `_imp___ZNK7ID3_Tag4SizeEv'
undefined reference to `_imp___ZN7ID3_TagD1Ev'
undefined reference to `_imp___ZN7ID3_TagD1Ev'
(several few, same format: `_imp___xxxxx_Tagxxxx')

I know what causes undefined reference, but in my case, why the linker couldn't find the implementation? Is it now there in the id3lib.dll? Does anyone know if there is any workaround?

Was it helpful?

Solution

The problem lies not in tool chains, but ABI.

It does exist standard plain C ABI, so you can link against both lib and a by MinGw, if they contain only plain C symbols.

But it is not true in you case (since such define as ID3_CPP_EXPORT exist).

You should try to make library by youserlf. To begin with, install msys, open msys shell, go to project folder and try

./configure && make

OTHER TIPS

Since you are not using Visual Studio that support .lib files to link your project to the right DLL you need id3lib.a (or something similar). GNU tool chain is different from MS one so you need the right static link files. My advice is to compile the library on your own on your compiler, since it is open source it's worth doing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top