What is the C runtime library?

Yes, libcmt is (one of several) implementations of the C standard library provided with Microsoft’s compiler. They provide both “debug” and “release” versions of three basic types of libraries: single-threaded (always statically linked), multi-threaded statically linked, and multi-threaded dynamically linked (though, depending on the compiler version you’re using, some of those may not be present).

So, in the name “libcmt”, “libc” is the (more or less) traditional name for the C library. The “mt” means “multi-threaded”. A “debug” version would have a “d” added to the end, giving “libcmtd”.

As far as what functions it includes, the C standard (part 7, if you happen to care) defines a set of functions a conforming (hosted) implementation must supply. Most vendors (including Microsoft) add various other functions themselves (for compatibility, to provide capabilities the standard functions don’t address, etc.) In most cases, it will also contain quite a few “internal” functions that are used by the compiler but not normally by the end user.

The runtime library is basically a collection of the implementations of those functions in one big file (or a few big files–e.g., on UNIX the floating point functions are traditionally stored separately from the rest). That big file is typically something on the same general order as a zip file, but without any compression, so it’s basically just some little files collected together and stored together into one bigger file. The archive will usually contain at least some indexing to make it relatively fast/easy to find and extract the data from the internal files. At least at times, Microsoft has used a library format with an “extended” index the linker can use to find which functions are implemented in which of the sub-files, so it can find and link in the parts it needs faster (but that’s purely an optimization, not a requirement).

If you want to get a complete list of the functions in “libcmt” (to use your example) you could open one of the Visual Studio command prompts (under “Visual Studio Tools”, normally), switch to the directory where your libraries were installed, and type something like: lib -list libcmt.lib and it’ll generate a (long) list of the names of all the object files in that library. Those don’t always correspond directly to the names of the functions, but will generally give an idea. If you want to look at a particular object file, you can use lib -extract to extract one of those object files, then use dumpbin /symbols <object file name> to find what function(s) is/are in that particular object file.

Leave a Comment