Technical Support

GENERAL: MAKING YOUR OWN LIBRARY FILES


Information in this article applies to:

  • CARM All Versions
  • C166 All Versions
  • C251 All Versions
  • C51 All Versions

SYMPTOMS

I generated a library file (.lib) using the library manager and expected that if I compiled an independent source file and linked it with the library, the linker would take care of only pulling in the functions that were referenced. However, the linker is including all functions in each module from the library and I'm getting linker warnings about these uncalled functions.

CAUSE

Libraries are composed of object modules (which are composed of variables and functions). The smallest unit the linker can manipulate is an object module. So, when you reference a function from a library, the linker includes the entire object module that contains that function. This is only a problem when one object module in your library contains more than one function.

RESOLUTION

The only way to solve this problem is to build your library with one function per source file. Then, when the linker includes a segment from the library, only one function is included. This is the way that most professional libraries are created.

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Saturday, February 05, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure