所以我在 WinRT 组件中使用 TagLib 并尝试获取 mp3 文件的专辑艺术,然后将它们保存到单独的文件中。到目前为止,我正在使用此代码:
auto albumartFolder = ApplicationData::Current->LocalFolder;
StorageFile^ destStorageFile = create_task(albumartFolder->CreateFileAsync("\\AlbumArts\\" + destFileName + ".jpg")).get();
TagLib::MPEG::File mpegFile(file->Path->Data());
static const char *IdPicture = "APIC";
TagLib::ID3v2::Tag *id3v2tag = mpegFile.ID3v2Tag();
TagLib::ID3v2::FrameList Frame;
TagLib::ID3v2::AttachedPictureFrame *PicFrame;
void *RetImage = NULL, *SrcImage;
unsigned long Size;
FILE *jpegFile;
jpegFile = fopen((char*)destStorageFile->Path->Data(), "wb");
if (id3v2tag)
{
Frame = id3v2tag->frameListMap()[IdPicture];
if (!Frame.isEmpty())
{
for (TagLib::ID3v2::FrameList::ConstIterator it = Frame.begin(); it != Frame.end(); ++it)
{
PicFrame = (TagLib::ID3v2::AttachedPictureFrame *)(*it);
if ( PicFrame->type() ==
TagLib::ID3v2::AttachedPictureFrame::FrontCover)
{
Size = PicFrame->picture().size();
SrcImage = malloc(Size);
if (SrcImage)
{
memcpy(SrcImage, PicFrame->picture().data(), Size);
fwrite(SrcImage, Size, 1, jpegFile);
fclose(jpegFile);
free(SrcImage);
}
}
}
}
}
这段代码应该没有我知道的错误,但这里是我收到的异常:
1>LibraryModule.obj : error LNK2019: unresolved external symbol "public: __thiscall TagLib::FileName::FileName(wchar_t const *)" (??0FileName@TagLib@@QAE@PB_W@Z) referenced in function "public: bool __thiscall <lambda_88d334404ef137d46dbb027b26f435b8>::operator()(void)const " (??R<lambda_88d334404ef137d46dbb027b26f435b8>@@QBE_NXZ)
1>LibraryModule.obj : error LNK2019: unresolved external symbol "public: __thiscall TagLib::MPEG::File::File(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (??0File@MPEG@TagLib@@QAE@VFileName@2@_NW4ReadStyle@AudioProperties@2@@Z) referenced in function "public: bool __thiscall <lambda_88d334404ef137d46dbb027b26f435b8>::operator()(void)const " (??R<lambda_88d334404ef137d46dbb027b26f435b8>@@QBE_NXZ)
1>LibraryModule.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall TagLib::MPEG::File::~File(void)" (??1File@MPEG@TagLib@@UAE@XZ) referenced in function "public: bool __thiscall <lambda_88d334404ef137d46dbb027b26f435b8>::operator()(void)const " (??R<lambda_88d334404ef137d46dbb027b26f435b8>@@QBE_NXZ)
对此的任何帮助将不胜感激!
编辑: 所以,这被标记为重复,但我仍然无法解决问题。如何正确链接 Taglib?我安装了 Nuget 包,我这样做错了吗?