ARCHIVED: Determine whether a routine exists within a library file in Linux

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

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 2023-04-21 16:55:53.