__declspec(dllimport)在QT中处于发布模式和调试模式

时间:2020-06-25 12:55:09

标签: c++ qt cmake taglib

我想在Windows上的QT项目中使用taglib,所以我从如下源代码构建taglib和zlib:

cmake CMakeLists.txt
cmake --build --config release

cmake命令使用Visual Studio编译器,我使用上述命令从源代码构建zlib和taglib,没有错误,我将它们的include和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

但是当我在发布模式下运行应用程序时,以上错误只是一些警告,而应用程序运行没有问题,为什么会这样? 谢谢。

0 个答案:

没有答案