Create a Project - CPP Examples¶
Prerequisite¶
Create a Visual Studio project from scratch¶
What would you like to do?
dialog,Create a new project
File->Close Solution
and then, from the menu select
File->New->Project...
Create a new project
dialog,Empty Project
and click NextConfigure your new project
dialog,Project1
for example, and set the location to C:\MAGICLANE
Debug
and x64
Project1
C:\MAGICLANE\Project1\
was created.Copy required files¶
Copy the following files
ApiLogger.h
Environment.cpp
Environment.h
Listeners.cpp
Listeners.h
OpenGLContext.cpp
OpenGLContext.h
Timer.cpp
Timer.h
C:\MAGICLANE\maps-sdk-examples-for-cpp-master\Examples\
C:\MAGICLANE\Project1\
Right-click on Header Files
, and select Add->Existing Item...
C:\MAGICLANE\Project1
Right-click on Source Files
, and select Add->Existing Item...
Copy the file
CenterMap.cpp
C:\MAGICLANE\maps-sdk-examples-for-cpp-master\Examples\D3Scene\CenterMap\
C:\MAGICLANE\Project1\
Source Files
, and select Add->Existing Item...
CenterMap.cpp
then click AddThis file is the starting point of the new application.
Create this directory:
C:\MAGICLANE\SDK\3rdParty\GLFW\lib\x64\
GLFW.lib
fromC:\MAGICLANE\maps-sdk-examples-for-cpp-master\BUILD_WIN\Maps-SDK-Examples-for-Cpp\Lib\x64\Debug\
C:\MAGICLANE\SDK\3rdParty\GLFW\lib\x64\
This is the GLFW3 graphics library which was built in the prerequisite guide.
Configure the project¶
Right-click on Project1 and select Properties
Verify these settings at the top of the dialog are as follows:
Configuration: All Configurations
Platform: x64
Configuration Properties->C/C++->General
Additional Include Directories
$(SolutionDir)..\SDK\Include
$(SolutionDir)..\SDK\3rdParty\ANGLE\include
$(SolutionDir)
$(SolutionDir)..\maps-sdk-examples-for-cpp-master\Examples\3rdParty\GLFW\deps
$(SolutionDir)..\maps-sdk-examples-for-cpp-master\Examples\3rdParty\GLFW\include
This configures the locations of include files and dependencies,
used for building the project, relative to the solution directory,
which is C:\MAGICLANE\Project1\
unless you changed it.
Configuration Properties->C/C++->Preprocessor
Preprocessor Definitions
and add:
WIN64;_WINDOWS;_CRT_SECURE_NO_WARNINGS
This preprocessor definition is required for a successful build: _CRT_SECURE_NO_WARNINGS
Configuration Properties->Linker->General
Additional Library Directories
$(SolutionDir)..\SDK\Lib
$(SolutionDir)..\SDK\3rdParty\ANGLE\lib\x64
$(SolutionDir)..\SDK\3rdParty\GLFW\lib\x64
This configures the locations of libraries
used for building the project, relative to the solution directory,
which is C:\MAGICLANE\Project1\
unless you changed it.
Configuration Properties->Linker->Input
Additional Dependencies
GEMStatic_d.lib
GLFW.lib
libEGL.dll.lib
libGLESv2.dll.lib
Ws2_32.lib
Shlwapi.lib
Kernel32.lib
Psapi.lib
Add the above libraries. The first one is the Magic Lane SDK, the next 3 are 3rd party graphic libraries, and the last 4 are system libraries.
This configures the names of actual libraries (dependencies)
used for building the project, relative to the solution directory,
which is C:\MAGICLANE\Project1\
unless you changed it.
Configuration Properties->General
Output Directory
and set it to:
$(SolutionDir)..\BUILD_WIN\$(SolutionName)\Bin\$(Platform)\$(Configuration)\
C:\MAGICLANE\BUILD_WIN\
C:\MAGICLANE\
unless you changed it.C:\MAGICLANE\SDK\
C:\MAGICLANE\Project1\
C:\MAGICLANE\Project2\
C:\MAGICLANE\ProjectN\
C:\MAGICLANE\BUILD_WIN\
Intermediate Directory
and set it to:
$(SolutionDir)..\BUILD_WIN\$(SolutionName)\Obj\$(Platform)\$(Configuration)\$(ProjectName)\
The directory containing the object files resulting from the compile.
Configuration Properties->Build Events->Post-Build Event
Command Line
and add:
xcopy /D /Q /Y "$(SolutionDir)..\SDK\3rdParty\ANGLE\bin\$(Platform)\*.dll" "$(OutDir)"
This will copy the dll libraries to the directory where the compiled executable is located, because that is the easiest way for the executable to find its dlls at runtime.
Set your API key token¶
Set your API key token in the std::string projectApiToken = "";
string in the main() function, before env.InitSDK()
is called.