0

As stated, I want to be able to check that a shared library, created by libtool, is not missing any symbols,

I have written a library that is built as a shared library, 'A'. It depends in turn on another library 'B'.

The other library 'B' does not follow strict semver, and so sometimes introduces new functions in minor or patch releases.

Although I try to put appropriate #if B_LIB_VERSION >= 42 in the code for my library to not attempt to call a function in library B if it is not going to be available, apparently I sometimes get the version incorrect. This causes an error when the program is run.

Is it possible with libtool, or any other tool, to ask it to produce a list of all the symbols that are not found in a shared library, or any of the libraries that it will load?

Danack
  • 24,939
  • 16
  • 90
  • 122

1 Answers1

0

As stated, I want to be able to check that a shared library, created by libtool, is not missing any symbols,

That's hard to do with shared libraries, as they are designed to allow for late symbol resolution. If you're not using dlopen type features, you might be able to build static executables from static versions of A and B and look for missing symbols.

The other library 'B' does not follow strict semver, and so sometimes introduces new functions in minor or patch releases.

I'd seriously consider searching for a replacement library, than having to keep on dealing with their dependency issues.

Is it possible with libtool, or any other tool, to ask it to produce a list of all the symbols that are not found in a shared library, or any of the libraries that it will load?

No, not really. nm will give you a list of symbols that are undefined (and referenced) in a shared library. objdump might be of some use also. On linux, ldd might do some of what you want. But generally there is no way of knowing exactly what a shared library loads, even without considering dlopen.

libltdl might be of some use also if you have to stick with the misbehaving library. At least you can figure out at runtime if libB.42 has symbol xyz or not. It's not as easy as the conditional code way of doing things.

Community
  • 1
  • 1
ldav1s
  • 15,885
  • 2
  • 53
  • 56