Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Index Visual C++ and MFC Fundamentals


22.1 Introduction to Libraries.............................................................................


22.1.1..Overview...............................................................................................


A library is a group of functions, classes, or other resources that can be made available to
programs that need already implemented entities without the need to know how these
functions, classes, or resources were created or how they function. Although a library can
appear as a complete program, in the strict sense, it is not. For example, it cannot be
executed by a casual user and it cannot execute its own program. A library makes it easy
for a programmer to use a function or functions, a class or classes, a resource or resources
created by another person or company and trust that this external source is reliable and
efficient. Although the issue or creating or implementing a library may appear
intimidating, it is absolutely not. There are only two difficult aspects of a library: 1)Why
do you need a library? And what do you want to put in a library? As you see, these two
“difficult” aspects we mention have nothing to do with programming. We can also state
that we do not have an answer to either of these questions: it will be up to you. What we
will do here is to show HOW to create a library, not why. We will also show how to
include things in a library. We will not define WHY you should put this function and not
that one in a library because, from our experience, it always depends on the programmer,
the project, or a group of people working on an application.

22.1.2..Libraries Characteristics.....................................................................


A library is created and functions like a normal regular program, using functions or other
resources and communicating with other programs. To implement its functionality, a
library contains functions that other programs would need to complete their functionality.
At the same time, a library may use some functions that other programs would not need.
For this reason, there are two types of functions you will create or include in your
libraries. An internal function is one used only by the library itself: the program that use
the library, also called the clients of the library, will not need access to these functions.
External functions are those that can be accessed by the clients of the library.

There are two broad categories of libraries you will deal with in your programs: static
libraries and dynamic libraries. The process of creating each makes the biggest
difference, not necessarily their functionalities. Even so, there are various techniques
used to create each category (once again, we insist on stating that the process of creating
a library will be the least difficult of your tasks).

Microsoft Visual C++ 6 already brought various options for creating or configuring a
library. Visual C++ .Net has gone even further by providing a lot more choices and
improvements. The types available are static libraries, Win32 dynamic link libraries
(DLLs) and MFC DLLs.

22.2 General Static Libraries..............................................................................


22.2.1..Introduction..........................................................................................


A static library is a file that contains functions, classes, or resources that an external
program can use to complement its functionality. To use a library, the programmer has to
Free download pdf