Ubuntu – Finding the library versions a library was linked against

librariesUbuntu

I have a library that was compiled on an unknown Ubuntu machine, And I'd like to determine what version of Ubuntu that machine had at the compile time.

My idea was to try and find the versions of different libraries used (e.g. the kernel), knowing that these versions changed with different releases. Iv'e tried using nm and ldd, but I can't seem to find any relevant info.

Any suggestions?

Best Answer

Maybe

 readelf -a 

It displays information about ELF files. If the object you are studying still contains the comment section, you may try to extract it by

 readelf -p .comment yourfile

For example

$ cat test.c
int main () {
  return 0;
}
$ gcc test.c
$ readelf -p .comment a.out

String dump of section '.comment':
  [     0]  GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

objdump could provide the same information.

If the comment section is stripped, you may try to read the GCC runtime symbol version info from the readelf -a command if it is a c++ compiled library. Note, that is the version of symbols supplied to the compiler and not necessarily the version of the compiler. I don't know how useful that would be to track down the Ubuntu version.

Related Question