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.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.