«

»

Aug 22

Setting up the Windows project

:Basic file structure for XPat project

 

Example diagram:

 

אייקון-SettingUpTheWindowsProject.png

Theoretical Background:

The developing environment that we will use to develop our common-XPlat code is windows, and we will use Visual Studio as our development tool.

 

We will create a new Static Library project in VS and call it CrossPlatformProjectExampleCore which will be the project we will use in order to compile the common XPlat code.

 

Note:

It is a static library and it will not be used to run the code, we will create a different project which is a console project that will use this static library in order to run just as a playground our XPlat code.

 

After we created the project we will:

1. Add the pch.h file to our XPlat Code inc folder.

2. Add the pch.cpp file to out CrossPlatformProjectExampleCore folder. (This file will be used to generate the CrossPlatformProjectExampleCore.pch file)

3. Add some source files and header files to our XPlat code. (In this example it will be the Calculator and Adder files.

 

Setting up the project:

 

A little background about pre compiled headers:

We will use pre compiled header in our project, this means that we will have a header file in our project – pch.h which will be included in all our cpp file.

Pre compiled headers are used in order to reduce compilation time as the pch.h will be compiled once and it will generate under our project Debug folder the CrossPlatformProjectExampleCore.pch, this is the compiled file of the pch.h.

Every cpp file we use will be marked with the option: “Precompiled header: Use (/Yu)

Except the pch.cpp which will be marked with the option: “Precompiled header: Create (/Yc)

 

Steps to set up the project in VS:

 

1. Add the inc folder to our project path:

 

2. Set the project to use the pch file:

 

3. Set the pch.cpp to generate the pch file:

 

4. Set to auto include the pch.h to all our cpp files

This is a nice shortcut so we won’t have to add the #include “pch.h” line to all our cpp files:

 
 

Now when we build the project it will build our XPlat code and under our CrossPlatformProjectExample solution folder, under Debug, it will generate our dll:

CrossPlatformProjectExampleCore.lib

 
 

Link to download the example project

 
 

That is it,

In the next article I will go over creating an example playground exe project that will use our newly create common core static library.

 

Good luck !

Leave a Reply

Your email address will not be published.

אתם יכולים להשתמש באפשרויות ותגי ה-HTMLהבאים: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>