2016-11-18 22 views
2

TagLibライブラリを使用するプロジェクトを作成しようとしています。私はそれについてどのように正確に行くのか分からない。Qtプロジェクトにライブラリを含める方法

私はTagLib 1.11.1をダウンロードしました。

次のように私はそれを建て:

ビルドの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:構成=デバッグINSTALL.vcxproj MSBuildの/ P:設定=リリースINSTALL.vcxproj

同じように多くのTagLibのをビルドします。

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 =オン-DWITH_MP4 =オン-DBUILD_EXAMPLES =オン msbuild/P:構成=解放ASE INSTALL.vcxproj

は、私は簡単なQtのコンソールアプリケーションを作成します。

enter image description here

私はその後、TagLibのからtag.libを追加Qtの

のQtを使用してE:\workspace\lib\installed\libに上記のビルド - >ライブラリの追加 - >ライブラリタイプ(外部ライブラリ) - > .......

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

答えて

0

あなたはVisual StudioTagLibzlibをコンパイルしている、あなたは(少なくとも、それは私がエラーメッセージから推測できるものです)mingwでプロジェクトをコンパイル。これは動作しません。まったく同じコンパイラですべてのライブラリとアプリケーションをコンパイルする必要があります。

Visual Studiogccのシンボル 'のようgccVisualを見ることができないs' は異なるABIを持っています。

関連する問題