Linux library file version

Просмотр информации о библиотеке Linux / исполняемой версии

В Windows EXE и DLL имеют информацию о версии, включая, по крайней мере, следующие поля:

  1. версия файла
  2. версия продукта
  3. внутреннее имя
  4. наименование товара
  5. авторское право

В Linux Library / Исполняемый файл:

  • Какие поля присутствуют?
  • Как просмотреть такую ​​информацию?
  • Какие инструменты / библиотеки читать?

Информация о версии явно не сохраняется в файле ELF . У вас есть название библиотеки, в soname которую входит основная версия. Полная версия обычно хранится как часть имени файла библиотеки.

Если у вас есть, скажем libtest.so , библиотека , то у вас обычно есть:

  • libtest.so.1.0.1 — сам файл библиотеки, содержащий полную версию
  • libtest.so.1 — Ссылка на libtest.so.1.0.1 , имеющая то же имя, что и soname
  • libtest.so — Симлинк, libtest.so.1 используемый для ссылки.

В файле библиотеки libtest.so.1.0.1 будет SONAME динамическая секция, которая будет называть эту библиотеку вызываемой libtest.so.1 . Когда вы связываете программу с этой библиотекой, связанная программа будет хранить входящую soname библиотеку NEEDED в динамическом разделе.

Если вы хотите проверить, что именно находится в ELF-файле, вы можете попробовать запустить:

где elffile может быть библиотека исполняемого файла.

Если вы просто хотите получить версию библиотеки, вы можете поиграть с:

AFAIK, такой информации нет (по крайней мере, по умолчанию) в исполняемых файлах.

Или вы можете положиться на саму программу или свою систему упаковки, как писал Рахул Патил.

Источник

Change Linux shared library (.so file) version after it was compiled

I’m compiling Linux libraries (for Android, using NDK’s g++, but I bet my question makes sense for any Linux system). When delivering those libraries to partners, I need to mark them with a version number. I must also be able to access the version number programatically (to show it in an «About» dialog or a GetVersion function for instance).

I first compile the libraries with an unversioned flag (version 0.0 ) and need to change this version to a real one when I’m done testing just before sending it to the partner. I know it would be easier to modify the source and recompile, but we don’t want to do that (because we should then test everything again if we recompile the code, we feel like it would be less error prone, see comments to this post and finally because our development environment works this way: we do this process for Windows binaries: we set a 0.0 resources version string (.rc) and we later change it by using verpatch. we’d like to work with the same kind of process when shipping Linux binaries).

Читайте также:  Как избавится от черного экрана при загрузке windows

What would be the best strategy here? To summarize, requirements are:

  1. Compile binaries with «unset» version ( 0.0 or anything else)
  2. Be able to modify this «unset» version to a specific one without having to recompile the binary (ideally, run a 3rd party tool command, as we do with verpatch under Windows)
  3. Be able to have the library code retrieve it’s version information at runtime

If your answer is «rename the .so», then please provide a solution for 3.: how to retrieve version name (i.e.: file name) at runtime.

I was thinking of some solutions but have no idea if they could work and how to achieve them.

  • Have a version variable (one string or 3 int ) in the code and have a way to change it in the binary file later? Using a binary sed.
  • Have a version variable within a resource and have a way to change it in the binary file later? (as we do for win32/win64)
  • Use a field of the .so (like SONAME) dedicated to this and have a tool allowing to change it. and make it accessible from C++ code.
  • Rename the lib + change SONAME (did not find how this can be achieved). and find a way to retrieve it from C++ code.
  • .

Note that we use QtCreator to compile the Android .so files, but they may not rely on Qt. So using Qt resources is not an ideal solution.

Источник

Find out library version

I want to find out what version of a C library is installed in my system (Ubuntu 12.04). In particular, I’m interested in libnuma. What is the proper way to do it?

3 Answers 3

I would use dpkg -l | grep libnuma1 to get the version.

Читайте также:  Windows 10 pro tib

As an example, I have ran dpkg -l on xterm and you can see that I’m running versoin 278-4 of xterm.

The file name or contents won’t always keep track of the exact version, so you’d typically want to use the packaging system facilities. For Ubuntu, you can either go to packages.ubuntu.com, search for your file, and see what version of the package is in your version of Ubuntu.

Or from the command line, you can first search for the name of the associated package using dpkg -S /usr/lib/libnuma.so.1 , which probably returns libnuma1 as the package name. Then run apt-cache showpkg libnuma1 to find the package version. The apt-cache output can be pretty long, but the version should be in the first few lines.

Not the answer you’re looking for? Browse other questions tagged linux ubuntu version or ask your own question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How to control shared library version issue on Linux?

For example, I create a shared library named libXXX.so.0.0.0 with the soname as libXXX.so.0. So, do I need to create a symlink named libXXX.so.0 and let it points to the real shared library? Or do I just need to create a symlink named libXXX.so?

Besides, what if I update the library to libXXX.so.0.0.1?

If I install the shared library on the system library path, such /lib or /usr/lib , how to update the symlink? Using ldconfig?

If I install the shared library on current local folder, how to update the symlink?

BTW, how control the version issue in Makefile? I mean do I need to add some command such as ln -s or ldconfig?

1 Answer 1

Yes, create a symlink named libXXX.so.0 pointing to libXXX.so.0.0.0 .

If you want people to be able to construct programs that are linked against this library then also create a symlink named libXXX.so pointing to libXXX.so.0 .

The libXXX.so.0 symlink will be used by the program loader, because that’s the soname that the program will be looking for.

Читайте также:  Xiaomi notebook pro windows hello

The libXXX.so symlink will be used by the linker when it is building a program, because by historical convention that’s how the linker works.

Besides, what if I update the library to libXXX.so.0.0.1?

Then you remake the libXXX.so.0 symlink so that it points to libXXX.so.0.0.1 . Nothing else needs to change. Since the libXXX.so symlink points to libXXX.so.0 it will automatically also point to the new library.

If you’re installing the new library by using some packaging system (RPM, . ) then use whatever feature the packaging system provides for managing symlinks. If you’re just using a script or a Makefile stanza then simply rm -f the old symlink and ln -s the new one.

Источник

Viewing Linux Library / Executable version info

In Windows, EXE and DLL have version info, including at least the following fields:

  1. file version
  2. product version
  3. internal name
  4. product name
  5. copyright

In Linux Library / Executable:

  • Which fields are present?
  • How to view such info?
  • What tools/libraries to read?

4 Answers 4

The version info in not explicitly stored in an ELF file. What you have in there is the name of the library, the soname , which includes the major version. The full version is usually stored as a part of the library file name.

If you have library, say libtest.so , then you usually have:

  • libtest.so.1.0.1 — The library file itself, containing the full version
  • libtest.so.1 — Symlink to libtest.so.1.0.1 , having the same name as soname
  • libtest.so — Symlink to libtest.so.1 used for linking.

In the library file libtest.so.1.0.1 , there will be an entry called SONAME in dynamic section, that will say this library is called libtest.so.1 . When you link a program against this library, the linked program will store the soname of the library under NEEDED entry in the dynamic section.

If you want to verify, what exactly is in which ELF file, you can try to run:

where elffile can be either an library of an executable.

If you simply want to get the library version, you can play with:

AFAIK, there’s no such info (at least not by default) in executable files.

Or you can rely on the program itself or your packaging system, as Rahul Patil wrote.

Источник

Оцените статью