create a simple static library and implement it on a Console
Have at least Visual
Studio C++ 2008 Express Edition in installed in your PC.
Build Static Library Project
Create new project
Select Project type as General. Template as Empty Project. I set the
name of the project as MyMathLib. After you set the name press OK.
Win32 Application Wizard dialog will pop-up. Press Next, and check on
the Application type option Static Library, and in additional options
you can unchecked precompiled options.
you will have to write the code for your classes, properties and
functions that you need to implement. Let’s write some simple
functions for our libraries First we need to create one header
file to declare the two functions. These functions will be named as
add and multiply.
functions will received two integer arguments, and return an integer
int add(int number_a, int number_b);
int multiply(int number_a, int number_b);
we declared let’s write the definition of our functions in a .cpp
int add(int number_a, int number_b)
return (number_a) + (number_b);
int multiply(int number_a, int number_b)
return (number_a) * (number_b);
F7 to build the library solution. If we go to our Debug or Release
folder (depending our compiling configuration), our output file will
be the static library. That means our that our library can be
implemented in any Visual C++ project. Let’s use these function in
a Console Application.
Implementing the Static Library
to solution explorer, and do right click on the Solution Item, then
go Add -> New Project.
project type as Win32 and the template as Win32 Console Application.
Then click OK. I named my project TestMyMathLib.
the Win32 Application Wizard window, press Next. Make sure the
Application type is Console Application and in Additional Options
have selected empty.
the solution explorer go to your Win32 Application projecto root
item, press right click, and in submenu click on the option Set as
start writing any code in the Win32 App. Project, we need to set a
registry our Static Library Project as a dependency. So again, in the
solution explorer go to your Win32 Application projecto root item,
press right click, and in submenu click on the option Project
Project Dependencies windows will pop-up. On the Dependencies tab,
make sure that your Win32 App Project is selected. Then on the list
of dependencies select your Static Library Project.
the Build Order tab, make sure your Static Library Project is build
before your Win32 App Project
a cpp file for Win32 Application project and write the following
using namespace std;
int main ()
cout << "Testing my math lib" << endl;
cout << "Please enter a number ";
int number_a, number_b;
cin >> number_a;
cout << "Please enter another number ";
cin >> number_b;
cout << "The addition result for these numbers is ";
cout << add(number_a, number_b);
cout << endl;
cout << "The multiply result for these numbers is ";
cout << multiply(number_a, number_b);
cout << endl;
F7 to build the solution. And press F5 to run and debug your
is how the application should look.
I've working since 2009. I started as a intern programming in SQL Server and C# language for a metallurgical factory of my hometown as Software support, debugging and patching the company system.
Now I'm working as a developer programming in Java and C++ in a company dedicated to mobile software.
I'm using third party home-brew tools, python and batch script to build releases.