Daily Blog C++: Static Library Creation

Josh P (Pixel Grim)
3 min readFeb 5, 2024

--

In my previous blog, I created a Utiltily CPP and header file. These files contained useful functions that I could call in my main CPP or include in another file to help make my life easier.

The goal today is to separate these files into their own project and make them into a static library.

This was done by creating a new empty project into the existing solution.

I transferred the files from the CppPrj into the Utility Project through Windows Explorer.

Then I right-clicked the Utility and added existing files.

For the Utility project, we must change how it’s built. Right-clicking Utility properties and change the Configuration Type to static library and build the project.

To make sure the Main CPP can use the utility files #include “Utility.h”. Need to add the location of where the file is stored within the additional include directories property in the main project.

Next is to make sure to link the project with the newly created Utility LIB file. Within my main CPP project in properties then Linker and additional dependencies I added the location where the Utility LIB file is located. Using the following: $(SolutionDir)$(Platform)\$(Configuration)\Utility.lib.

Finally, right-click the solution folder and ensure the solution/project is dependent on the Utilities LIB file in case we make adjustments to the LIB file.

--

--