1.11. Building a Static Library with an IDE
Problem
You wish to use your IDE to build a static library from a collection of C++ source files, such as those listed in Example 1-1.
Solution
The basic outline is as follows:
Create a new project and specify that you wish to build a static library rather than an executable or a dynamic library.
Choose a build configuration (e.g., debug versus release, single-threaded versus multithreaded).
Specify the name of your library and the directory in which it should be created.
Add your source files to the project.
If necessary, specify one or more directories where the compiler should search for included headers. See Recipe 1.13.
Build the project.
The steps in this outline vary somewhat depending on the IDE; for example, with some IDEs, several steps are combined into one or the ordering of the steps is different. The second step is covered in detail in Recipe 1.21, Recipe 1.22, and Recipe 1.23. For now, you should use default settings as much as possible.
For example, here’s how to build a static library from the source code in Example 1-1 using the Visual C++ IDE.
Select New→ Project from the File menu, select Visual C++[9] in the left pane, select Win32 Console Application, and enter libjohnpaul as your project’s name. From the Win32 Application Wizard go to Application Settings, select Static library, uncheck Precompiled header, and press Finish. You should now have an empty project with two build configurations, Debug and Release, the former being ...