mac os x 上的 libstdc++6.dylib 版本号是什么意思?

What is the meaning of the libstdc++6.dylib version number on mac os x?

我试图通过 Mac OS X (Yosemite 10.10.3) 上的 gcc5.1 端口来确定哪个版本的 libstdc++ 运行。

otool 命令提供以下信息:

/opt/local/lib/libgcc/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.21.0)

version 7.21.0是什么意思? libstdc++7 真的存在吗?

如果要查找libstdc++的版本对应的GCC版本号,这样做:

$> port provides /opt/local/lib/libgcc/libstdc++.6.dylib

这将告诉您哪个端口安装了给定的文件。在我的例子中,那是 libgcc,我假设它对你来说是一样的。要找出当前安装的 libgcc 版本,请使用 port installed:

$> port installed libgcc

在我的系统上,那是 libgcc @5.1.0_1 (active),因此 libstdc++ 的版本对应于 GCC 5.1 附带的版本。

请注意,OS X 上的兼容版本与库文件名中给出的版本号不同。它更相当于 Linux 系统上的次要版本号。有关详细信息,请参阅 https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW23,具体适用于此部分:

In addition to the major version number, a library has a minor version number. The minor version number is an incremental number using the format X[.Y[.Z]] , where X is a number between 0 and 65535, and Y and Z are numbers between 0 and 255. For example, the minor version number for the first release of the Draw library could be 1.0. To set the minor version number of a dynamic library, use the clang -current_version option.

The compatibility version number is similar to the minor version number; it’s set through the compiler -compatibility_version command-line option. The compatibility version number of a library release specifies the earliest minor version of the clients linked with that release can use. For instance, the example in Defining Client Compatibility indicates that Client 1.1 cannot use versions of the Draw library earlier than 1.2 because they don’t export the draw_polygon function. To view a library’s current and compatibility versions, use the otool -L command.