In Linux, how can I determine whether a routine exists within a library file?

In Linux, to check whether a routine exists within a library file, use the nm command with the -g option, and pipe the output to grep.

For example, to check whether the cos function exists within the shared version of the standard math library (libm.so), on the Linux command line, enter (replace /path/to/libm.so with the location where libm.so is installed on your system):

  nm -g /path/to/libm.so | grep " cos"

Alternatively, to check whether the cos function exists within the static version of the same library (libm.a), use the ar command with the -t option and pipe the output to grep; for example (replace /path/to/libm.a with the location where libm.a is installed on your system):

  ar -t /path/to/libm.a | grep " cos"
Note:
In both examples above, cos is preceded by a space.

For more about nm and ar, see each command's manual page.

This is document aqoz in the Knowledge Base.
Last modified on 2017-05-25 16:09:55.

Contact us

For help or to comment, email the UITS Support Center.