0

We have been porting our Java API to C++, and creating a library file (.a file) for Linux. Our API has dependency on the boost framework and also on log4cxx. (We discussed with the first user for this, and they are okay with those dependencies).

When I compile a sample application which uses our library file, it is linking against .so files for the dependencies (libboost_system.so, libboost_thread.so, and liblog4cxx.so). When the application runs, it needs to find the specific versioned file names for each of those .so files, e.g. liblog4cxx.so.10.

If the user is using a newer version of boost (for example), would s/he be able to link against their local version and run with that newer version (assuming bacwards compatibility)? Is there some other way to deal with versions/dependencies like these (i.e. do you try to link in the external referenced libraries to your own library)?

4

1 回答 1

1

是的,该程序可以链接到具有兼容接口的较新库。文件名中的数字对库应用程序二进制接口 (ABI) 进行编码。

FreeBSD 的手册有更多关于库版本控制的信息。基本规则是:

  • 从 1.0 开始
  • 如果有向后兼容的更改,则增加次要编号(请注意,ELF 系统会忽略次要编号)
  • 如果有不兼容的更改,请增加主编号

链接器将整理细节以使用具有兼容接口的最新库版本。这里还有更多关于 stackoverflow 的信息。

于 2013-07-22T17:31:00.113 回答