T0: Setting up Visual Studio Project
Download and install the IDE
You will need an editor to write and compile your code to start using the library. We recommend Microsoft Visual Studio 2019.
Download the Visual Studio installer from here.
The installer allows you to configure the editor and add modules to it.
In the Workloads tab, check the Desktop development with C++ option.
Note
If you installed VS without the C++ module already, do not bother. Rerun the installer, 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 on 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#include <HIRO/HIRO.h>
2
3int main()
4{
5 hiro::SetAssetDirectory("./HIRO/resources/");
6 hiro::SetIntermediateDirectory("./temp/");
7
8 hiro::Initialize();
9
10 while (hiro::IsOpen())
11 {
12 hiro::Update();
13 }
14
15 hiro::Terminate();
16 return 0;
17}
Add Libraries to Project
Download the latest version of the 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
When you download a newer library version, replace the library folder’s contents.
Right-click on the project name in Solution Explorer. Choose the Properties option at the bottom of the list. At the top, change the Configuration dropdown to the 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 are 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, or it will 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 than \ 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, or you will 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
The current release version uses some of the features deprecated in the C++17 standard and advanced features from the 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
The current release version produces multiple warnings when your project is being built.
We recommend ignoring this warning in your project by going to C/C++ > Advanced > Disable Specific Warnings and adding 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.