c++ - __declspec(dllimport) 在 QT 中的发布模式和调试模式
问题描述
我想在 Windows 上的 QT 项目中使用 taglib,所以我从源代码构建 taglib 和 zlib,如下所示:
cmake CMakeLists.txt
cmake --build --config release
cmake 命令使用 Visual Studio 编译器,我使用上述命令从源代码构建 zlib 和 taglib 没有错误,我将它们的包含和 lib 路径添加到 QT 项目 .pro 文件,如下所示:
INCLUDEPATH+=F:\project\TAGLIB\taglib\taglib F:\project\TAGLIB\taglib\taglib\toolkit F:\project\TAGLIB\taglib F:\project\zlib-1.2.11\Release F:\project\zlib-1.2.11
LIBS+=-LF:\project\zlib-1.2.11\Release -lzlib
LIBS+= -LF:\project\TAGLIB\taglib\taglib\Release -ltag
LIBS+=-LF:\project\TAGLIB\taglib\taglib\Debug -ltag
LIBS+=-LF:\project\zlib-1.2.11\Debug -lzlibd
在 main.cpp 我添加了:
#include<fileref.h>
#include<tag.h>
#include<QDebug>
在主要功能中:
TagLib::FileRef f("C:\\Users\\sub\\Downloads\\Mohsen Chavoshi - Sharhe Alef.mp3");
TagLib::String artist = f.tag()->artist();
当我在调试模式下运行我的应用程序时,它没有运行并给我以下错误:
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl TagLib::String::~String(void)" (__imp_??1String@TagLib@@UEAA@XZ) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __cdecl TagLib::String::toCString(bool)const " (__imp_?toCString@String@TagLib@@QEBAPEBD_N@Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl TagLib::FileName::FileName(char const *)" (__imp_??0FileName@TagLib@@QEAA@PEBD@Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl TagLib::FileRef::FileRef(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (__imp_??0FileRef@TagLib@@QEAA@VFileName@1@_NW4ReadStyle@AudioProperties@1@@Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl TagLib::FileRef::~FileRef(void)" (__imp_??1FileRef@TagLib@@UEAA@XZ) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: class TagLib::Tag * __cdecl TagLib::FileRef::tag(void)const " (__imp_?tag@FileRef@TagLib@@QEBAPEAVTag@2@XZ) referenced in function main
debug\testTag2.exe:-1: error: LNK1120: 6 unresolved externals
但是当我在发布模式下运行应用程序时,上述错误只是一些警告并且应用程序运行没有问题,为什么会发生这种情况?谢谢你。
解决方案
推荐阅读
- namespaces - Python 库基础知识
- java - HashMap 上的 Java 8 getOrDefault 方法未按预期工作
- python - mod_cgi + utf8 + Python3 不产生输出
- tableau-api - 如何为 Tableau 用户提供下拉列表以在交叉表中选择要下载的列
- ios - 根据需要在每个自定义 UITableViewCell 上设置分隔符插图
- python - 熊猫不会重命名多索引列名
- excel - 添加新数据行时更新图表
- nativescript - Sidekick 和 xCode 之间的 Nativescript App 版本控制差异
- javascript - 悬停时带有图像的菜单
- sql-server - 从一行字符串中提取最大的数字