Wednesday 16 November 2011

Why should I create a library? in C programming

Why should I create a library?

Creating a function library enables you to put reusable functions in a place where they can be shared with other programmers and programs. For instance, you might have several general-purpose utility functions that are used in several of your programs. Instead of duplicating the source code for all of these different programs, you can put these functions in a centralized function library and then link them into your program when the linker is invoked. This method is better for program maintenance, because you can maintain your functions in one centralized place rather than several places.

If you are working in a team environment, putting your reusable functions in a library allows other programmers to link your functions into their programs, saving them from having to duplicate your effort and write similar functions from scratch. Additionally, in large projects that involve several modules, a function library can be used to contain “framework” support functions that are used throughout theapplication.Your compiler includes a library manager (typically named LIB.EXE or something similar) that can be used to add and delete object code modules (.obj’s) from function libraries. Some compilers enable you tomaintain your libraries from within their integrated development environments without having to invokea library manager manually. In any case, you should refer to the answers to FAQ XVIII.7 and XVIII.8 for important information regarding the creation of libraries and good techniques to adhere to.

Cross Reference:

XVIII.7: Are all the functions in a library added to an .EXE file when the library is linked to the
objects?
XVIII.8: Can multiple library functions be included in the same source file?

No comments:

Post a Comment