# T0: Setting up Visual Studio Project

## Download and install the IDE

To start to use the library, you will need an editor to write and compile your code. We recommend Microsoft Visual Studio 2019.

1. Download Visual Studio installer from here.

2. The installer allows you to configure the editor and add modules to it.

3. In the Workloads tab, check the Desktop development with C++ option.

Note

If you installed VS without the C++ module already, do not bother. Run the installer again, in More dropdown select Modify to download and install additional modules.

## Create the Project

After starting Visual Studio, choose Create a new project. Select Empty Project. Here you give a descriptive project name, select project location, name your solution, then click Create.

Warning

Before progressing further, set the platform from x86 to x64 in your top toolbar. The libraries for x86 configuration are not provided nor supported.

Add your first source file main.cpp. Navigate to the Solution Explorer panel at the right. If the panel is hidden, go to View > Solution Explorer, or Ctrl + Alt + L to open it again. Right-click on the Source Files, and select Add > New Item…. In the pop-up window select Visual C++, then C++File (.cpp). Finally, name it main.cpp. Click Add.

Copy and paste the code block below into main.cpp and ignore IntelliSense errors for now. We will fix them later.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    #include <HIRO/HIRO.h>

    int main()
    {
      hiro::SetAssetDirectory("./HIRO/resources/");
      hiro::SetIntermediateDirectory("./temp/");

      hiro::Initialize();

      while (hiro::IsOpen())
      {
      hiro::Update();
      }

      hiro::Terminate();
      return 0;
    }

## Add Libraries to Project

Download the latest version of HIRO library bundle from the main page Introduction. Extract the downloaded zip file and copy the contents (directory `HIRO`, that containing `lib`, `bin`, `resources` etc.) into your project folder.

Hint

Whenever you download newer version of library, replace the contents of the library folder.

Right-click on the project name in Solution Explorer. Choose the Properties option on the bottom of the list. At the top, change the Configuration dropdown to All Configurations option.

We will set up the include directory path first. Select VC++ Directories in the left menu, then click on row Include Directories. Click on the dropdown, then <Edit…> and add `HIRO/include` and `HIRO/ThirdParty/include` folders.

Now, we will set up the library directory path. Select VC++ Directories in the left menu, then click on row Library Directories. Click on the dropdown, then <Edit…> and add `HIRO/lib/$(Configuration)` and `HIRO/ThirdParty/lib/$(Configuration)` folders. The `$(Configuration)` macro ensures, that the libraries used located in the folder that matches the currently selected configuration, in our case Debug or Release.

The last directory we set is the binaries directory path. Binaries (.dll files) are linked when the application is started and are searched for in the folder that contains the application .exe file. Usually you copy all the .dll files to the same directory where .exe is present, otherwise, it would not find them. However, Visual Studio offers a nicer option to use an external folder for binaries. Select Debugging in the left menu, then set the Environment path using the string `PATH=HIRO/bin/$(Configuration);HIRO/ThirdParty/bin/$(Configuration);`

Attention

Do not forget the `;` mark at the end!

In every case, you should use `/` rather then `\` to avoid weird path errors.

At last, we set up the libraries we wish to use in our project. Select Linker > Input in the left menu, then click Additional Dependencies. Click on the dropdown, then <Edit…>. Add the libraries, each on a separate line as follows: `HIRO_msvc141_v0.4.0.lib` `COGS_msvc141_v0.1.0.lib` `glbinding.lib`. Make sure the library versions match the files located in `HIRO/lib/Release` folder. Later, if you need any other libraries in your project (such as `HIRO_DRAW` in the following tutorials), add them to this list, otherwise, you get linker errors.

## Allow C++17 Standard

HIRO takes advantage of the C++17 features. Set the C++ version in your project by going to project properties and C/C++ > Language > C++ Language Standard > ISO C++17 Standard (/std:c++17)

Note

Current version of release use some of the features deprecated in C++17 standard, as well as advanced features from glm library. Therefore, you need to go to C/C++ > Preprocessor > Preprocessor Definitions and add in the preprocessor definitions `_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS` and `GLM_ENABLE_EXPERIMENTAL`.

Note

Current version of release produces multiple warnings when your project is being built. We recommed ignoring this warning in your project by going to C/C++ > Advanced > Disable Specific Warnings and add in `4251`.

Try to run the application, it should compile without any errors. Now you are ready to go to the T1: Introduction to HIRO GUI.