Search code examples
cgccgnuglibc

The number of functions in C library


I want to know there are how many functions I can call in C library, e.g. Gnu C library? or Approximately?


Solution

  • If you are in unix like OS, you can use nm utility, part of gnu binutils. In my cygwin environment, nm lists 1570 symbols defined in the text section.

    % nm -C /usr/lib/libc.a  | grep -w T | wc -l
    1570
    

    Let's exclude the _ variants

    % nm -C /usr/lib/libc.a  | grep -w T | grep -v _ | wc -l
    751
    

    If you are on windows, try dumpbin utility.

    % dumpbin /exports msvcr110.dll
    

    -C in the nm command demangles the symbol names. I do not know how to get dumpbin to print original symbol names. If anyone knows how to, please suggest.

    Some functions might be defined in another object file - like libm for math, libnsl for network services etc. To be sure, also look at the library documentation/source.