为 Windows 编译静态 TagLib 1.6.3 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3878883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:22:38  来源:igfitidea点击:

Compiling static TagLib 1.6.3 libraries for Windows

c++windowsqtcmaketaglib

提问by jocull

I am having a super hard time compiling and using TagLib 1.6.3 in my Qt project. I've tried everything I can think of. TagLib claims that it is supported through CMake but I'm not having any luck. Furthermore, I'm confused about what kinds of files I even need for my Qt libs!

我在我的 Qt 项目中编译和使用 TagLib 1.6.3 非常困难。我已经尝试了所有我能想到的。TagLib 声称它是通过 CMake 支持的,但我没有任何运气。此外,我对我的 Qt 库甚至需要什么样的文件感到困惑!

I've built *.a files, *.lib, and *.dll. From what I understand thus far... I believe that since I'm working in Windows *.lib is what I want. No matter what I do, I always end up with "undefined references" to any TagLib functions I try to use when I try to compile my Qt project. I have tried MinGW32, MSYS, Visual Studio 2008, and even cross-compiling for Windows on Linux. All turning up nothing.

我已经构建了 *.a 文件、*.lib 和 *.dll。从我到目前为止的理解来看......我相信因为我在 Windows *.lib 中工作是我想要的。无论我做什么,当我尝试编译我的 Qt 项目时,我总是以“未定义的引用”结束我尝试使用的任何 TagLib 函数。我尝试过 MinGW32、MSYS、Visual Studio 2008,甚至在 Linux 上为 Windows 进行交叉编译。一切都没有出现。

What makes even less sense to me is that if I compile the same TagLib source with Qt on Mac (g++ I think?) it works fine! Somewhere in my Windows compilation procedures I have to be going wrong. I have been smacking my face on my desk for probably about 30 (on and off) hours trying to figure this out.

对我来说更没有意义的是,如果我在 Mac 上用 Qt 编译相同的 TagLib 源代码(我认为是 g++?),它运行良好!在我的 Windows 编译程序的某个地方,我一定会出错。我一直在我的桌子上打我的脸大约 30 个小时(断断续续)试图弄清楚这一点。

Since Qt uses minGW must I compile TagLib with the same compiler?

由于 Qt 使用 minGW,我必须使用相同的编译器编译 TagLib 吗?

If I compile *.lib's with Visual Studio are they not compatible?

如果我用 Visual Studio 编译 *.lib,它们不兼容吗?

Are *.a libraries even usable in Windows? (assuming minGW)

*.a 库甚至可以在 Windows 中使用吗?(假设minGW)

I'm still trying to get a handle on this C++ stuff, but after reading countless forum threads and other questions I'm still coming up short. Here is what I have been working with in CMake currently...

我仍在尝试处理这个 C++ 的东西,但在阅读了无数的论坛主题和其他问题后,我仍然没有得到解决。这是我目前在 CMake 中使用的内容......

cmake -G "MinGW Makefiles" -DENABLE_STATIC=ON -DHAVE_ZLIB=0 -DWITH_MP4=1 -DMAKE_TAGLIB_LIB=1
cmake --build ./

This generates a single *.a file of ~2MB in size. The working library on Mac was ~3MB, and the *.lib from Visual Studio was ~4MB in Release mode. Please someone save me from this C++ cross platform command line madness because I am at my wit's end. I would probably even pay you to just compiling me some %!$#&ing libraries. Thanks.

这会生成一个大约 2MB 的 *.a 文件。Mac 上的工作库约为 3MB,Visual Studio 中的 *.lib 在 Release 模式下约为 4MB。请有人把我从这个 C++ 跨平台命令行的疯狂中拯救出来,因为我已经无能为力了。我什至可能会付钱给你,让我编译一些 %!$#&ing 库。谢谢。

采纳答案by WolfgangP

Since Mac works for you, I'm just talking about Win32.

由于 Mac 适合你,我只是在谈论 Win32。

Ok, this are my Taglib.pro and an excerpt of my project.pro: https://gist.github.com/449ea81ce92f52399f41. Check them out. My Taglib may be a bit outdated, so take care, some files you may have could be missing there. Also take care of the relative paths. They are all relative to the .pro file.

好的,这是我的 Taglib.pro 和我的 project.pro 的摘录:https://gist.github.com/449ea81ce92f52399f41 。去看一下。我的 Taglib 可能有点过时,所以请注意,您可能会丢失一些文件。还要注意相对路径。它们都与 .pro 文件相关。

I just ran cmake .inside the taglib directory. This should result in a config.hand a taglib_config.h

我只是cmake .在 taglib 目录中运行。这应该导致 aconfig.h和 ataglib_config.h

You definitly only need the libTaglib.awhen you use QtCreator and mingw-gcc. *.lib are MSVC specific!

libTaglib.a当您使用 QtCreator 和 mingw-gcc 时,您肯定只需要。*.lib 是 MSVC 特定的!

回答by Name is carl

This blog postdetails the whole process described in this thread.

这篇 博文详细介绍了该线程中描述的整个过程。

The blog post author, Joel, was nice enough to provide the binaries of taglib 3.6.3compiled for windows.

博文作者 Joel 提供了为 Windows 编译的 taglib 3.6.3二进制文件

回答by Craig

I use cmake for my projects.Here is my cmake file for a media player I made that uses taglib. I installed taglib to /usr/local/ (this way I don't have to change anything when I compile in Linux). The important parts have an arrow.

我在我的项目中使用 cmake。这是我为使用 taglib 制作的媒体播放器的 cmake 文件。我将 taglib 安装到 /usr/local/ (这样我在 Linux 中编译时不必更改任何内容)。重要的部分有一个箭头。

project(qtmu3)
find_package(Qt4 REQUIRED)
-> find_library(TAGLIB_LIB tag PATH /usr/local/lib/)
set(QT_USE_PHONON TRUE)
set(QTMU_SRCS main.cpp mainwindow.cpp WidgetMarqueeLabel.cpp single_application.cpp)
set(QTMU_MOC_HDRS mainwindow.h WidgetMarqueeLabel.h single_application.h)
set(QTMU_UI_FILES mainwindow.ui)
set(QTMU_RSRC_FILES myresources.qrc)
-> include_directories(/usr/local/include/taglib/)
set(CMAKE_CXX_FLAGS "-mwindows")
include(${QT_USE_FILE})
QT4_WRAP_UI( QTMU_UI_HDRS ${QTMU_UI_FILES})
QT4_WRAP_CPP( QTMU_MOC_SRCS ${QTMU_MOC_HDRS})
QT4_ADD_RESOURCES(QTMU_RSRC_SRCS ${QTMU_RSRC_FILES})
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
ADD_EXECUTABLE(qtmu3 ${QTMU_SRCS} ${QTMU_MOC_SRCS} ${QTMU_RSRC_SRCS} ${QTMU_UI_HDRS})
-> TARGET_LINK_LIBRARIES(qtmu3 ${QT_LIBRARIES} ${TAGLIB_LIB}) 

The last one, just the ${TAGLIB_LIB} is important. hope that helps someone.

最后一个,只有 ${TAGLIB_LIB} 很重要。希望能帮助某人。