View Full Version : How to include id3lib library in Qt (Windows)
Divad
11th January 2014, 21:31
Hello,
I want to use id3libs library, but I can't include it. How come ?
- I have downloaded libraries here (http://id3lib.sourceforge.net/) (.h, .dll, .lib, .exp and .a).
- I put all these files in one folder, so I've got this :
-> audioProject/
- a.mp3
- audioProject.pro
- audioProject.pro.user
- audioProject.cpp
- audioProject.h
- id3.h
- main.cpp
-> id3/
- field.h
- globals.h
- id3lib.dll
- id3lib.lib
- ...
- I have added bellow lines in my .pro file :
INCLUDEPATH += $$PWD/id3/
LIBS += -L$$PWD/id3/ -lid3lib
HEADERS += audioProject.h # I did not included id3lib headers
- I wrote these lines in my audioProject.cpp file :
#include <id3/tag.h>
- But when I try an example, I've got errors :
ID3_Tag tag("a.mp3");
Here are compilation errors :
undefined reference to ID3_Tag::ID3_Tag(char const*)
undefined reference to ID3_Tag::~ID3_Tag()
"undefined reference" is because of bad libraries inclusion. But in my case, I am confused. :(
How can I fix it ? (I am using Qt 5.1.1, Qt Creator 4.8.2 on Windows 7 64 bits).
Thank you
Infinity
12th January 2014, 00:04
Which compiler do you use? You can't use a library built with msvc when compiling your own application with MinGW for example.
Divad
12th January 2014, 00:17
Yes, I am using MinGW.
I see g++ -c -pipe XXX in my compiler log.
So what should I change ?
ChrisW67
12th January 2014, 01:55
You could start by posting the entire linker command that lead to the error.
Edit:
Actually, you need to build the C++ id3 library with MingW if your project is compiled with MingW. The id3lib.lib file indicates you have an MSVC built C++ library.
Divad
12th January 2014, 04:28
This is my compiler log :
C:/Qt/Qt5.1.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]:
Entering directory 'C:/Users/David/Documents/Qt Project/build-audioProject-Desktop_Qt_5_1_1_MinGW_32bit-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG
-DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\audioProject -I"..\audioProject\id3"
-I"..\..\..\..\..\Qt\Qt5.1.1\5.1.1\mingw48_32\include" -I"..\..\..\..\..\Qt\Qt5.1.1\5.1.1\mingw48_32\include \QtWidgets"
-I"..\..\..\..\..\Qt\Qt5.1.1\5.1.1\mingw48_32\include \QtGui" -I"..\..\..\..\..\Qt\Qt5.1.1\5.1.1\mingw48_32\include \QtCore"
-I"debug" -I"." -I"." -I"..\..\..\..\..\Qt\Qt5.1.1\5.1.1\mingw48_32\mkspecs \win32-g++" -o debug\audioProject.o ..\audioProject\audioProject.cpp
In file included from ..\audioProject/id3/utils.h:37:0,
from ..\audioProject/id3/tag.h:34,
from ..\audioProject\audioProject.cpp:14:
..\audioProject/id3/id3lib_strings.h:102:7: warning: unused parameter '__c' [-Wunused-parameter]
to_char_type(const int_type& __c)
^
..\audioProject/id3/id3lib_strings.h:106:7: warning: unused parameter '__c' [-Wunused-parameter]
to_int_type(const char_type& __c) { return int_type(); }
^
In file included from ..\audioProject/id3/id3lib_frame.h:31:0,
from ..\audioProject/id3/tag.h:32,
from ..\audioProject\audioProject.cpp:14:
..\audioProject/id3/globals.h:542:20: warning: 'ID3_v1_genre_description' defined but not used [-Wunused-variable]
static const char *ID3_v1_genre_description[ID3_NR_OF_V1_GENRES] =
^
g++ -Wl,-subsystem,windows -mthreads -o debug\audioProject.exe debug/main.o debug/audioProject.o debug/about.o debug/qrc_images.o
debug/moc_audioProject.o debug/moc_about.o -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmaind
"-LC:/Users/David/Documents/Qt Project/audioProject/id3/" -lid3lib -LC:\Qt\Qt5.1.1\5.1.1\mingw48_32\lib -lQt5Widgetsd -lQt5Guid -lQt5Cored
debug/audioProject.o: In function `ZN3audioProject22on_folder_view_clickedERK11QMode lIndex':
C:\Users\David\Documents\Qt Project\build-audioProject-Desktop_Qt_5_1_1_MinGW_32bit-Debug/../audioProject/audioProject.cpp:96: undefined reference to `ID3_Tag::ID3_Tag(char const*)'
C:\Users\David\Documents\Qt Project\build-audioProject-Desktop_Qt_5_1_1_MinGW_32bit-Debug/../audioProject/audioProject.cpp:96: undefined reference to `ID3_Tag::~ID3_Tag()'
collect2.exe: error: ld returned 1 exit status
Makefile.Debug:86: recipe for target 'debug\audioProject.exe' failed
mingw32-make[1]: Leaving directory 'C:/Users/David/Documents/Qt Project/build-audioProject-Desktop_Qt_5_1_1_MinGW_32bit-Debug'
makefile:34: recipe for target 'debug' failed
mingw32-make[1]: *** [debug\audioProject.exe] Error 1
mingw32-make: *** [debug] Error 2
As you can see, libraries path are right, but they are not accepted.
I think it is really because I use MinGW.
How can I rebuild it to work with MinGW ?
ChrisW67
12th January 2014, 06:28
Download id3lib source
Read instructions
Build
Edit: You may need a full MingW/MSys environment and it may not compile unmodified.
Divad
17th January 2014, 17:51
The solution was to update my gcc version.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.