c++ - 将 TagLib 链接到 Qt 时出错

标签 c++ qt cmake linker-errors taglib

如果我尝试在我的代码中引用外部 TagLib 库(例如 TagLib::FileRef f(path);),那么当我构建我的 Qt Creator 项目时,我会遇到以下错误,

symbol(s) not found for architecture x86_64
linker command failed with exit code 1 (use -v to see invocation)

Undefined symbols for architecture x86_64:
  "_inflate", referenced from:
      TagLib::zlib::decompress(TagLib::ByteVector const&) in libtag.a(tzlib.cpp.o)
  "_inflateEnd", referenced from:
      TagLib::zlib::decompress(TagLib::ByteVector const&) in libtag.a(tzlib.cpp.o)
  "_inflateInit_", referenced from:
      TagLib::zlib::decompress(TagLib::ByteVector const&) in libtag.a(tzlib.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Opus.app/Contents/MacOS/Opus] Error 1
21:06:29: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Opus (kit: Desktop Qt 5.7.0 clang 64bit)
When executing step "Make"

我的 .pro 文件,

QT       += core gui sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Opus
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    tabunit.cpp \
    tabholder.cpp \
    dbmanager.cpp \
    articleadditiondialog.cpp \
    articlefilemodel.cpp \
    directoryiterator.cpp \
    articleattributes.cpp

HEADERS  += mainwindow.h \
    tabunit.h \
    tabholder.h \
    dbmanager.h \
    articleproperty.h \
    articleadditiondialog.h \
    articlefilemodel.h \
    directoryiterator.h \
    articleattributes.h

FORMS    += mainwindow.ui \
    articleadditiondialog.ui

LIBS += -L$$PWD/../../../Libraries/taglib-1.11.1/taglib/ -ltag

INCLUDEPATH += $$PWD/../../../Libraries/taglib-1.11.1/include

在/Libraries/taglib-1.11.1/我有 this .

如有任何帮助,我们将不胜感激。

最佳答案

已添加

LIBS += -lz

到 .pro 文件

关于c++ - 将 TagLib 链接到 Qt 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42215679/

相关文章:

c++ - Qml与C++交互: return by pointer or by copy

c++ - 尝试在 Windows 上的 CLion+CMake+MinGW 中编译 OpenGL 4 Helloworld。 "undefined reference to ` _imp____glewCreateShader'“错误

c++ - cmake:库依赖于另一个库(sqlite3pp)

c++指向const类成员的指针问题

c++ - 捕获重复组的正则表达式

c++ - 不可用的 Ui 属性

c++ - cmake如何找到包?

c++ - 是否有可能让 getline() 函数接受 wistream&

c++ - 在C++中将字符转换为字符串

c++ - 如何使用 Qt 从缓冲区加载图像?