How to Configure the Library Project in C++

By John Paul Mueller, Jeff Cogswell

The static library starts with a standard C file. To make this library work well with templates, you need to delete the C file, add a C++ file, and add a header file. The following steps describe how to perform this process:

1Right-click main.c in the Projects tab of the Management window and choose Remove File From Project from the context menu that appears.

Code::Blocks removes the file from the project tree.

2Choose File→New→File.

You see the New from Template dialog box shown.

3Highlight the C/C++ Header icon and click Go.

You see the Welcome page of the C/C++ Header wizard.

4Click Next.

The wizard asks you to provide the header configuration information.

5In the Filename with Full Path field, type MathLibrary.h, click the ellipses button, and then click Save.

Code::Blocks adds the complete project path to the filename you chose. Notice that Code::Blocks also supplies an entry for the Header Guard Word field. This word ensures that the header isn’t added more than once to a project.

6Click All, and then click Finish.

The C/C++ Source wizard adds the file to your project. You’re ready to begin creating a template library.