编译的共享库依赖于特定的libicuuc.so.46版本

时间:2022-01-23 06:29:52

I am compiling a shared library using g++ on SUse Linux with cmake that depends on libicuuc.so and friends.

我正在使用基于libicuuc.so和朋友的cmake在SUse Linux上使用g ++编译共享库。

Suse has libicuuc.so, libicuuc.so.46 and libicuuc.so.46.1 in /usr/lib.

Suse在/ usr / lib中有libicuuc.so,libicuuc.so.46和libicuuc.so.46.1。

Now when I use ldd to list the dependencies of my library it tells me that it depends on libicuuc.so.46.

现在,当我使用ldd列出我的库的依赖项时,它告诉我它依赖于libicuuc.so.46。

Since I want to distribute my library in binary form (it takes about 45 minutes to compile on a fast PC) this dependency is a problem. The target PCs have different versions of libicuuc.so.

由于我想以二进制形式分发我的库(在快速PC上编译需要大约45分钟),这种依赖性是一个问题。目标PC有不同版本的libicuuc.so。

What can I do so that my library depends on libicuuc.so and not libicuuc.so.46?

我能做些什么才能让我的图书馆依赖于libicuuc.so而不是libicuuc.so.46?

I tried to remove the so.46 versions in my /usr/lib folder before compiling but libicuuc.so depends on libicudata.so.46 so I keep that dependency on a 46 version what I try to avoid.

我试图在编译之前删除/ usr / lib文件夹中的so.46版本,但是libicuuc.so依赖于libicudata.so.46所以我将这种依赖性保留在我试图避免的46版本上。

1 个解决方案

#1


1  

Read about external library versioning here.

在这里阅读外部库版本控制。

What can I do so that my library depends on libicuuc.so and not libicuuc.so.46?

我能做些什么才能让我的图书馆依赖于libicuuc.so而不是libicuuc.so.46?

You can't do anything about that. The libicuuc.so that you have has SONAME set to libicuuc.so.46, and the linker dutifully records that dependency (as it should).

你无能为力。您拥有的libicuuc.so将SONAME设置为libicuuc.so.46,并且链接器尽职地记录该依赖项(应该如此)。

If developers release libicuuc.so.47, they would do so because the new library is not ABI-compatible with the old one (at least that's what they should do if they are not clueless).

如果开发人员发布libicuuc.so.47,他们会这样做,因为新库与旧库不兼容ABI(至少那是他们应该做的,如果他们不是一无所知)。

If your library loaded libcuuc.so.47 (as you want it to), it would most likely crash due to the ABI incompatibility. Or worse: corrupt your end user's data. So achieving your desired result would get you into worse trouble than what you have now (not running is better than randomly crashing or corrupting data).

如果您的库加载了libcuuc.so.47(如您所愿),它很可能会因ABI不兼容而崩溃。或者更糟:破坏最终用户的数据。因此,实现您想要的结果会让您遇到比现在更糟糕的问题(不运行比随机崩溃或损坏数据更好)。

Update:

The libicuuc.so documentation explicitly states that "Binary compatibility is for versions that share the same major+minor number."

libicuuc.so文档明确指出“二进制兼容性适用于共享相同主要+次要编号的版本”。

That means: you can't link a library compiled with version 4.6 (SONAME libicuuc.so.46) and expect it work with version 4.7.

这意味着:您无法链接使用版本4.6(SONAME libicuuc.so.46)编译的库,并期望它与版本4.7一起使用。

You must either rebuild your library for each version of ICUUC, or distribute matching libicuuc.so.NN with your library (and hope that the user is not already using some other version of libicuuc).

您必须为每个版本的ICUUC重建库,或者将匹配的libicuuc.so.NN与您的库一起分发(并希望用户尚未使用其他版本的libicuuc)。

Another possible alternative: statically link libicuuc.a into your library, and hide all of libicuuc.a symbols so they don't conflict with anything else. Note: this has licensing implications.

另一种可能的选择:将libicuuc.a静态链接到您的库中,并隐藏所有libicuuc.a符号,这样它们就不会与其他任何东西发生冲突。注意:这有许可意义。

#1


1  

Read about external library versioning here.

在这里阅读外部库版本控制。

What can I do so that my library depends on libicuuc.so and not libicuuc.so.46?

我能做些什么才能让我的图书馆依赖于libicuuc.so而不是libicuuc.so.46?

You can't do anything about that. The libicuuc.so that you have has SONAME set to libicuuc.so.46, and the linker dutifully records that dependency (as it should).

你无能为力。您拥有的libicuuc.so将SONAME设置为libicuuc.so.46,并且链接器尽职地记录该依赖项(应该如此)。

If developers release libicuuc.so.47, they would do so because the new library is not ABI-compatible with the old one (at least that's what they should do if they are not clueless).

如果开发人员发布libicuuc.so.47,他们会这样做,因为新库与旧库不兼容ABI(至少那是他们应该做的,如果他们不是一无所知)。

If your library loaded libcuuc.so.47 (as you want it to), it would most likely crash due to the ABI incompatibility. Or worse: corrupt your end user's data. So achieving your desired result would get you into worse trouble than what you have now (not running is better than randomly crashing or corrupting data).

如果您的库加载了libcuuc.so.47(如您所愿),它很可能会因ABI不兼容而崩溃。或者更糟:破坏最终用户的数据。因此,实现您想要的结果会让您遇到比现在更糟糕的问题(不运行比随机崩溃或损坏数据更好)。

Update:

The libicuuc.so documentation explicitly states that "Binary compatibility is for versions that share the same major+minor number."

libicuuc.so文档明确指出“二进制兼容性适用于共享相同主要+次要编号的版本”。

That means: you can't link a library compiled with version 4.6 (SONAME libicuuc.so.46) and expect it work with version 4.7.

这意味着:您无法链接使用版本4.6(SONAME libicuuc.so.46)编译的库,并期望它与版本4.7一起使用。

You must either rebuild your library for each version of ICUUC, or distribute matching libicuuc.so.NN with your library (and hope that the user is not already using some other version of libicuuc).

您必须为每个版本的ICUUC重建库,或者将匹配的libicuuc.so.NN与您的库一起分发(并希望用户尚未使用其他版本的libicuuc)。

Another possible alternative: statically link libicuuc.a into your library, and hide all of libicuuc.a symbols so they don't conflict with anything else. Note: this has licensing implications.

另一种可能的选择:将libicuuc.a静态链接到您的库中,并隐藏所有libicuuc.a符号,这样它们就不会与其他任何东西发生冲突。注意:这有许可意义。