在 Visual Studio 2010 中使用 TagLib

发布于 2024-10-07 06:06:43 字数 3675 浏览 2 评论 0原文

编辑:是的,我看过这篇文章。不幸的是,看起来用户最终还是使用了 MingW。


我使用的是 64 位 Windows 7。我从 SVN 存储库下载了最新版本的 TagLib 代码。我正在使用修订版1202935

我正在尝试在 Visual Studio 2010 中使用 TagLib。我已经让 TagLib 与 QtCreator/MingW 一起使用,但我想开始学习 Windows API,所以我从 Visual Studio 2010(当然是 C++)开始。

在VS2010中,我构建了zlib(静态和动态)以及带和不带zlib的TagLib(静态和动态)。换句话说,我已经尝试了一切我能想到的方法来让它发挥作用。

我的理想情况是使用 CMake 为 TagLib 生成 VS2010 项目文件(有一个用于 VS2010 64 位的选项。我选择此选项)。我希望它们是静态库,因此我启用 ENABLE_STATIC,并启用WITH_ASF 和WITH_MP4。我还使用 ZLIB_INCLUDE_DIR 和 ZLIB_LIBRARY 将 TagLib 定向到 zlib(我链接到之前使用 VS2010 构建的 zlib.lib 文件)。请注意,我使用的是 CMake GUI。

然后,我在 VS2010 中打开生成的项目文件,并对代码进行三处更改,以便它在 Visual Studio 2010 中构建时不会出现错误(我将修复程序放在这里,以供与我遇到相同问题的其他人使用 )。

apefooter.cpp 第 192 行:

std::bitset<32> flags(static_cast<unsigned long long>(data.mid(20, 4).toUInt(false)));

mpcproperties.cpp 第 116 行:

std::bitset<32> flags = static_cast<unsigned long long>(d->data.mid(8, 4).toUInt(false));

mpegheader.cpp 第 171 行:

std::bitset<32> flags(static_cast<unsigned long long>(data.toUInt()));

然后我注释掉第 436 行和 mpegfile.cpp 中的 437,因为 我认为这是一个错误

// ID3v2Tag(true);
// ID3v1Tag(true);

然后我在发布模式下构建项目。它构建得很好。没有错误(尽管有很多警告)。

所以我生成了tag.lib。然后我创建了一个测试 VS2010 项目/解决方案来使用 TagLib。

这是我使用 TagLib 的唯一一行。只是一个测试,请注意。

TagLib::MPEG::File a("tests/other/blank.mp3");
  • 我将 TAGLIB_STATIC 添加到所有配置(发布和调试版本)的预处理器选项(属性页 > 配置属性 > C/C++ > 预处理器 > 预处理器定义) )
  • 我将每一个该死的头目录添加到属性页>中配置属性> C/C++>一般>其他包含目录
  • 最后,我按顺序将 zlib.lib 和 tag.lib 添加到其他依赖项(属性页 > 配置属性 > 链接器 > 输入 > 其他依赖项

“哎呀!好麻烦啊!现在看看能不能成功?”

1>vs_taglib_test.obj : error LNK2028: unresolved token (0A00001A) "public: virtual __clrcall TagLib::MPEG::File::~File(void)" (??1File@MPEG@TagLib@@$$FUAM@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>vs_taglib_test.obj : error LNK2028: unresolved token (0A00001B) "public: __clrcall TagLib::MPEG::File::File(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (??0File@MPEG@TagLib@@$$FQAM@VFileName@2@_NW4ReadStyle@AudioProperties@2@@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>vs_taglib_test.obj : error LNK2019: unresolved external symbol "public: virtual __clrcall TagLib::MPEG::File::~File(void)" (??1File@MPEG@TagLib@@$$FUAM@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>vs_taglib_test.obj : error LNK2019: unresolved external symbol "public: __clrcall TagLib::MPEG::File::File(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (??0File@MPEG@TagLib@@$$FQAM@VFileName@2@_NW4ReadStyle@AudioProperties@2@@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)

其他人可以尝试我在这里所做的事情并指出我的错误吗?我试图提供足够的信息让大家看看发生了什么。

感谢您的阅读!

EDIT: Yes, I have looked at this post. Unfortunately, it looks like the user ends up using MingW in the end.


I am on Windows 7, 64-bit. I downloaded the most recent version of the TagLib code from the SVN repository. I am using revision 1202935.

I am trying to use TagLib in Visual Studio 2010. I have gotten TagLib to work with QtCreator/MingW, but I want to start learning the Windows API so I am starting from scratch in Visual Studio 2010 (C++ of course).

In VS2010, I have build zlib (both statically and dynamically) and TagLib with and without zlib (both statically and dynamically). In other words, I have tried everything I can think of to get this to work.

My ideal situation is that I use CMake to generate the VS2010 project files (there is an option for VS2010 64-bit. I do not choose this option) for TagLib. I would like them to be static libraries, so I enable ENABLE_STATIC, and I enable WITH_ASF, and WITH_MP4. I also direct TagLib to zlib using ZLIB_INCLUDE_DIR and ZLIB_LIBRARY (I am linking to the zlib.lib file that I previously built using VS2010). Note, I am using the CMake GUI.

I then open up the generated project files in VS2010 and make three changes to the code so that it build in Visual Studio 2010 without error (I put the fixes here for anyone else who had the same problem as I).

apefooter.cpp on line 192:

std::bitset<32> flags(static_cast<unsigned long long>(data.mid(20, 4).toUInt(false)));

mpcproperties.cpp on line 116:

std::bitset<32> flags = static_cast<unsigned long long>(d->data.mid(8, 4).toUInt(false));

mpegheader.cpp on line 171:

std::bitset<32> flags(static_cast<unsigned long long>(data.toUInt()));

I then make then comment out lines 436 and 437 in mpegfile.cpp, because I think it's a bug.

// ID3v2Tag(true);
// ID3v1Tag(true);

I then build the project in Release mode. It builds just fine. No errors (although there are a bunch of warnings).

So I have generated tag.lib. I then created a test VS2010 project/solution to use TagLib.

This is the only line I use TagLib. Just a test, mind you.

TagLib::MPEG::File a("tests/other/blank.mp3");
  • I added TAGLIB_STATIC to the preprocessor options (Property Pages > Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions) for all configurations (both Release and Debug builds)
  • I added every single darn header directory to Property Pages > Configuration Properties > C/C++ > General > Additional Include Directories
  • And finally I added zlib.lib and tag.lib to the additional dependencies (Property Pages > Configuration Properties > Linker > Input > Additional Dependencies) IN THAT ORDER

"Whew! What a hassle! Now let's see if it works?"

1>vs_taglib_test.obj : error LNK2028: unresolved token (0A00001A) "public: virtual __clrcall TagLib::MPEG::File::~File(void)" (??1File@MPEG@TagLib@@$FUAM@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>vs_taglib_test.obj : error LNK2028: unresolved token (0A00001B) "public: __clrcall TagLib::MPEG::File::File(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (??0File@MPEG@TagLib@@$FQAM@VFileName@2@_NW4ReadStyle@AudioProperties@2@@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>vs_taglib_test.obj : error LNK2019: unresolved external symbol "public: virtual __clrcall TagLib::MPEG::File::~File(void)" (??1File@MPEG@TagLib@@$FUAM@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>vs_taglib_test.obj : error LNK2019: unresolved external symbol "public: __clrcall TagLib::MPEG::File::File(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (??0File@MPEG@TagLib@@$FQAM@VFileName@2@_NW4ReadStyle@AudioProperties@2@@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)

Can someone else try out what I'm doing here and point out my mistake? I tried to provide enough information for y'all to see what's happening.

Thanks for reading!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

软甜啾 2024-10-14 06:06:43

我已经能够使用 Visual Studio 2010 构建 TagLib 1.7。

我的步骤

使用 CMake gui 会引发 ZLIB 错误,手动添加 zlib 目录和 lib 将生成 Visual Studio 解决方案,但不会生成 .dll 文件(链接错误)

I've been able to build TagLib 1.7 using Visual Studio 2010.

My Steps

Using the CMake gui throws up errors for ZLIB and adding the zlib directories and lib manually will generate a visual studio solution but it would not generate the .dll files (linking errors)

想你只要分分秒秒 2024-10-14 06:06:43

问题是__clrcall。您没有提到您的项目是 C++/CLI,但这是一个非常重要的细节。

人们使用其他库(例如 Oracle DB)时会遇到此问题

#pragma managed(push, off)
#include "taglib.h"
#pragma managed(pop)

让 Visual C++ 知道 taglib 是本机代码。

The problem is __clrcall. You didn't mention that your project is C++/CLI but that's a very important detail.

People have run into this with other libraries, like Oracle DB.

#pragma managed(push, off)
#include "taglib.h"
#pragma managed(pop)

to let Visual C++ know that taglib is native code.

抚你发端 2024-10-14 06:06:43

在代码中定义宏“TAGLIB_STATIC”!

示例

#define TAGLIB_STATIC

define the macro "TAGLIB_STATIC" in your code!

example

#define TAGLIB_STATIC

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文