我試圖創建一個使用TagLib庫的項目。我不確定如何去做。我已經下載TagLib 1.11.1。如何在Qt項目中包含一個庫
我建,如下所示:
構建zlib的,首先有CMake的創建一個Visual Studio解決方案文件,然後建立與Visual Studio這樣的解決方案:
的mkdir建立& & cd build cmake .. -G「Visual Studio 14 2015 Win64」-DCMAKE_INSTALL_PREFIX =「e:\ workspace \ lib \ installed」 msbuild/P:Configuration = Debug INSTALL.vcxproj 的MSBuild/P:配置=釋放INSTALL.vcxproj
建立標籤庫多以同樣的方式:
CD .... \的taglib-1.11.1 的mkdir建立& & CD編譯 cmake .. -G「Visual Studio 14 2015 Win64」-DCMAKE_INSTALL_PREFIX =「e:\ workspace \ lib \ installed」-DZLIB_INCLUDE_DIR =「e:\ workspace \ lib \ installed \ include」-DZLIB_LIBRARY =「e:\ workspace \ lib \ installed \ lib \ zlib.lib「-DWITH_ASF = on -DWITH_MP4 = on -DBUILD_EXAMPLES = on msbuild/P:Configuration = Rele ASE INSTALL.vcxproj
我創建一個簡單的Qt控制檯應用程序:
我再從標籤庫構建上述E:\workspace\lib\installed\lib
使用Qt
的Qt增加
tag.lib
- > Add Library - > Library Type (External Library) - > .......
main.cpp中:
#include <QCoreApplication>
#include <QDebug>
#include <taglib/fileref.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TagLib::FileRef f("D:/Dire Straits - Sultans of Swing.mp3");
return a.exec();
}
taglibtest.pro
QT += core
QT -= gui
CONFIG += c++11
TARGET = taglibtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
HEADERS += \
taglib/aifffile.h \
taglib/aiffproperties.h \
taglib/apefile.h \
taglib/apefooter.h \
taglib/apeitem.h \
taglib/apeproperties.h \
taglib/apetag.h \
taglib/asfattribute.h \
taglib/asffile.h \
taglib/asfpicture.h \
taglib/asfproperties.h \
etc....
etc....
我收到以下錯誤,每當我試圖建立在Qt的項目:
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE'
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
:-1: error: release/main.o: bad reloc address 0x0 in section `.ctors'
:-1: error: final link failed: Invalid operation
collect2.exe:-1: error: error: ld returned 1 exit status
應該是什麼我確實解決了這個問題並開始使用TagLib?
taglibtest.pro
QT += core
QT -= gui
CONFIG += c++11
TARGET = taglibtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
HEADERS += \
taglib/aifffile.h \
taglib/aiffproperties.h \
taglib/apefile.h \
taglib/apefooter.h \
taglib/apeitem.h \
taglib/apeproperties.h \
taglib/apetag.h \
taglib/asfattribute.h \
taglib/asffile.h \
taglib/asfpicture.h \
taglib/asfproperties.h \
etc....
etc....