Starting a New GCC Static Library Project

Why Static Libraries

Static Libraries (LIB) is a good way to reuse code. Rather than re-creating the same routines/functions in all the programs, the user can write them once and reference from the applications that need the functionality.

Create New Static Library Project

Figure 1. New Static Library Project

Click OK to create the Static Library project. A default source file with the same name as the project will be added to the solution. You may then write and compile your routines/functions. You can also add new source files or header files into the project.

Open the Project Properties on the menu Project'Your_project_name Properties'. This menu item is only available when a Static Library project is open. Select the Build property page. Here you will see that the Artifact Type is selected as Static Library.

Figure 2. Static Library Build Properties

Compile the project by selecting Build Solution from the Build menu. This creates a Static Library, which can be used by other programs.

Static Library Project Options (AVR/GNU Archiver)

The AVR/GNU archiver, avr-ar, combines a collection of object files into a single archive file, also known as a library.

Open the Project Properties on the menu Project'Your_project_name Properties'. This menu item is only available when a Static Library project is open. In order to configure Static Library options, click on the Toolchain property tab.

In the Toolchain property page, you will see AVR/GNU Archiver active and enabled. You may also see that the AVR/GNU Linker is disabled for a static library project.

Figure 3. AVR/GNU Archiver Setup Dialog, Command Line Shown

You can set the AVR/GNU Archiver flags at the Archiver Flags textbox in the above General options.

Now, save the project and compile by selecting Build Solution from the Build menu.