GENERAL: HOW TO STRUCTURE MODULES IN A LIBRARY
Information in this article applies to:
I am trying to create a library of functions, but each time I include it in my applications all the functions in the same file are included even if I do not use them. How should I structure the modules in a library file?
A module (object file) is the smallest translation unit that contains variables, functions, and so on. When the linker extracts variables or functions from a library, the whole module is included (not just the function or variable you use). It is not possible for the linker to extract anything smaller than a module from a library file.
While is is not possible for the linker to break a module into smaller blocks, it is possible to do this when creating the source files.
Basically, when creating a library, you should place only one function in a source file. Since each module will contain only one function (or one function and its support variables and routines) additional unused functions will not be included by the linker.
The following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Thursday, December 21, 2006
of your data.