Menu

Adding_KDIS_To_A_New-Existing_Project_Manually

Karl  Jones
Attachments
VS20081.png (55972 bytes)
VS20082.png (22712 bytes)
VS20083.png (86270 bytes)
VS20084.png (50030 bytes)
VS20085.png (44492 bytes)

Note: This guide is a little deprecated now, KDIS now requires certain files to be added/removed depending on the protocol version. I will try to update this page in the future and list the files that are required however I recommend you use Cmake to generate your project and then examine the generated project files if you still want a manually created project.


Windows - Visual Studio 2008 Express C++

Here is how to add KDIS to your Visual Studio project. Although I use Visual Studio 2008 in this guide the steps are exactly the same for Visual Studio 2003/2005/2008/2010.

Add KDIS Files

First we need to add the KDIS files. If you are linking against a libary version of KDIS (dll or lib) then this part is optional.

We have 2 choices here.

Option 1: The Quick But Messy Way

If you have extracted the KDIS zip file you should have a folder structure like this:
  • KDIS_vx-x-x

    • KDIS
    • Examples

    Drag the KDIS folder into your Visual Studio project side bar.

When we drag the folder into Visual Studio it extracts all *.h and *.cpp files for us and places them into _Source_ and _Header_ folders. If you are planning on building against a .lib version of KDIS you can delete the _Source_ folder.

This approach is quick but what if we want to maintain the KDIS folder hierarchy?

Option 2: The Slightly Longer But Neater Way

In this approach we want to maintain the KDIS folder hierarchy, I recommend doing this as it will make things much easier to find when you start using KDIS.

First we want to create the folder hierarchy.

Right click on the visual studio project in the solutions explorer and choose Add -> New Filter

Call the filter _KDIS_.

Now right click on the KDIS filter/folder that you just created and create a new filter, call this one _DataTypes_.

Repeat this until you have the whole folder hierarchy.

We now need to add the files to the folders.

Right click on the filter/folder _KDIS_ and select Add -> Existing Item

Navigate to the KDIS folder and select the files that are in the root.

Now right click on the filter/folder DataTypes and add all the .cpp/.h files. 
Repeat this for all the filters/folders we created.

**Note** If you are planning on building againt a .lib version of KDIS you dont need to include the cpp files.

Project Settings

Additional Include Directories

KDIS should now compile but with many messages/warnings.

We need to make a few more changes to our project.

First we should add the KDIS folder to the projects _Additional Include Directories_.

Project -> Properties(Alt + F7)

**Note**: The directory you should add to your project is the directory that contains the 2 sub directories called KDIS and Examples.

We can now include KDIS files without having to add the whole path.

E.G

#include "KDIS/KDataStream.h"

Preprocessor Definitions

We now need to define our _Preprocessor Definitions_
DIS_VERSION=X
We should tell KDIS what version of DIS we want to support.

E.G

DIS_VERSION=6

**Note:** Only DIS version 5, 6 and 7 are currently supported.

IMPORT_KDIS & EXPORT_KDIS
If you plan to use KDIS as a .dll then define IMPORT_KDIS in the _Preprocessor Definitions_.

If you want to build KDIS into a .dll then define EXPORT_KDIS.

**Note:** Do not define both EXPORT_KDIS and IMPORT_KDIS in the same project, this will cause an error.
KDIS_USE_ENUM_DESCRIPTORS
This will enable Enum Descriptors in your project. 
You can read more about them [ here.](Converting_Enumerations_Into_Their_String_Values_Tutorial_)

Linux - KDevelop C++

I plan to write a linux guide in the future, for the moment the windows guide should answer most questions. 
Note: From version **1-15-0** you need to add the rt (librt) library when building KDIS on Linux, this is for the timestamp auto calc feature which uses clock_gettime for a more accurate timestamp. To include the library on gcc adding a -lrt to the link options should do the trick.

Related

Wiki: Main_Page
Wiki: Manually_Creating_A_New_Project

MongoDB Logo MongoDB