1- # How to Build
1+ # How to Build and Run
22
33<!--
44Copyright (c) 2014-2021, The Khronos Group Inc.
55
66SPDX-License-Identifier: CC-BY-4.0
77-->
88
9- ## Python v3.6+ required
9+ ## Building
1010
11- Certain source files are generated at build time from the ` xr.xml ` file, utilizing
12- python scripts. The scripts make use of the python ` pathlib ` module, which is
13- fully supported in python version 3.6 or later.
11+ ### Python v3.6+ may be required
1412
15- You will also need the python ` jinja2 ` package, available from your package
16- manager or with something like ` pip3 install jinja2 ` .
13+ ** If you are building from most repostories:** (specifically, the
14+ OpenXR-SDK-Source repository, the OpenXR-CTS repository, or the internal Khronos
15+ GitLab OpenXR repository) Certain source files are generated at build time from
16+ the ` xr.xml ` file, utilizing Python scripts. The scripts make use of the Python
17+ ` pathlib ` module, which is fully supported in Python version 3.6 or later.
1718
18- ## Windows
19+ You will also need the Python ` jinja2 ` package, available from your package
20+ manager or with something like ` pip3 install jinja2 ` . Most OpenXR repositories
21+ include a bundled copy of this, but if you see errors about Jinja, this would be
22+ one approach to try.
1923
20- Building the OpenXR components in this tree on Windows is supported using Visual
21- Studio 2013 and newer. If you are using Visual Studio 2019, you can simply "Open
22- folder" and use the built-in CMake support. Other environments, such as VS Code,
23- that can have CMake support installed and use the Visual Studio toolchains,
24- should also work: the project is a relatively standard CMake-based project. You
24+ ** If you are building the ` OpenXR-SDK ` repository:** all source files have been
25+ pre-generated for you, and only the OpenXR headers and loader are included.
26+
27+ ### CMake
28+
29+ The project is a relatively standard CMake-based project. You
2530might consider
2631[ the official CMake User Interaction Guide] [ cmake-user-interaction ] if you're
27- new to building CMake-based projects.
32+ new to building CMake-based projects. The instructions below can mostly be skimmed to find the dependencies
2833
2934[ cmake-user-interaction ] :https://cmake.org/cmake/help/latest/guide/user-interaction/
3035
31- To easily build from the command line using the following steps, make sure the
32- appropriate ` msbuild.exe ` is in your PATH. Also, when generating the
36+ ### Windows
37+
38+ Building the OpenXR components in this tree on Windows is supported using Visual
39+ Studio 2013 and newer. If you are using Visual Studio 2019, you can simply "Open
40+ folder" and use the built-in CMake support. Other environments, such as VS Code,
41+ that can have CMake support installed and use the Visual Studio toolchains,
42+ should also work:
43+
44+ When generating the
3345solutions/projects using CMake, be sure to use the correct compiler version
3446number. The following table is provided to help you:
3547
@@ -40,11 +52,11 @@ number. The following table is provided to help you:
4052| Visual Studio 2017 | 15 |
4153| Visual Studio 2019 | 16 |
4254
43- ### Windows 64-bit
55+ #### Windows 64-bit
4456
4557First, generate the 64-bit solution and project files using CMake:
4658
47- ```
59+ ``` cmd
4860mkdir build\win64
4961cd build\win64
5062cmake -G "Visual Studio [Version Number] Win64" ../..
@@ -67,90 +79,104 @@ Installer -> Modify -> Individual Components -> C++ CMake tools for Windows. To
6779get the right paths for ` msbuild.exe ` and ` cmake.exe ` , you can launch through
6880` Start -> Visual Studio 2019 -> x64 Native Tools Command Prompt For VS 2019 ` .
6981
70- ### Windows 32-bit
82+ #### Windows 32-bit
7183
7284First, generate the 32-bit solution and project files using CMake:
7385
74- ```
86+ ``` cmd
7587mkdir build\win32
7688cd build\win32
7789cmake -G "Visual Studio [Version Number]" ../..
7890```
7991
8092Open the build\win32\OPENXR.sln in the Visual Studio to build the samples.
8193
82- ## Linux
83-
84- The following set of packages provides all required libs for building for xlib or xcb with OpenGL and Vulkan support.
85- - build-essential
86- - cmake (of _ somewhat_ recent vintage, 3.10+ known working)
87- - libgl1-mesa-dev
88- - libvulkan-dev
89- - libx11-xcb-dev
90- - libxcb-dri2-0-dev
91- - libxcb-glx0-dev
92- - libxcb-icccm4-dev
93- - libxcb-keysyms1-dev
94- - libxcb-randr0-dev
95- - libxrandr-dev
96- - libxxf86vm-dev
97- - mesa-common-dev
98-
99- ### Linux Debug
94+ #### (Optional) Building the OpenXR Loader as a DLL
10095
96+ The OpenXR loader is built as a static library by default on Windows. To instead
97+ build as a dynamic link library, define the cmake option ` DYNAMIC_LOADER=ON ` .
98+ e.g. for Win64, replace the CMake line shown above with:
99+
100+ ``` cmd
101+ cmake -DDYNAMIC_LOADER=ON -G "Visual Studio [Version Number] Win64" ../..
101102```
103+
104+ Note that even if built as a dynamic library, the loader ** should not** be
105+ installed system-wide on Windows or Android.
106+
107+ ### Linux
108+
109+ The following set of packages provides all required libs for building for xlib
110+ or xcb with OpenGL and Vulkan support.
111+
112+ - build-essential
113+ - cmake
114+ - libgl1-mesa-dev
115+ - libvulkan-dev
116+ - libx11-xcb-dev
117+ - libxcb-dri2-0-dev
118+ - libxcb-glx0-dev
119+ - libxcb-icccm4-dev
120+ - libxcb-keysyms1-dev
121+ - libxcb-randr0-dev
122+ - libxrandr-dev
123+ - libxxf86vm-dev
124+ - mesa-common-dev
125+
126+ #### Linux Debug
127+
128+ ``` sh
102129mkdir -p build/linux_debug
103130cd build/linux_debug
104131cmake -DCMAKE_BUILD_TYPE=Debug ../..
105132make
106133```
107134
108- ### Linux Release
135+ #### Linux Release (with debug symbols)
109136
110- ```
137+ ``` sh
111138mkdir -p build/linux_release
112139cd build/linux_release
113- cmake -DCMAKE_BUILD_TYPE=Release ../..
140+ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../..
114141make
115142```
116143
117- ## (Optional) Building the OpenXR Loader as a DLL
118-
119- The OpenXR loader is built as a static library by default. To instead build as a dynamic link library, define
120- the cmake option ` DYNAMIC_LOADER=ON ` . e.g. for Win64, replace the cmake line shown above with:
121-
122- ```
123- cmake -DDYNAMIC_LOADER=ON -G "Visual Studio [Version Number] Win64" ../..
124- ```
144+ ## Running the HELLO_XR sample
125145
126- # Running the HELLO_XR sample
146+ ### OpenXR runtime installation
127147
128- ## OpenXR runtime installation
148+ An OpenXR _ runtime_ must first be installed before running the ` hello_xr `
149+ sample. The runtime is an implementation of the OpenXR API, typically tailed to
150+ a specific device and distributed by the device manufacturer. Publicly-available
151+ runtimes are listed on the main OpenXR landing page at
152+ < https://www.khronos.org/openxr >
129153
130- An OpenXR _ runtime_ must first be installed before running the hello_xr sample. The runtime is an
131- implementation of the OpenXR API, typically tailed to a specific device and distributed by the
132- device manufacturer. To allow experimentation with the API in the absence of a specific device runtime,
133- several organizations have made available prototype OpenXR runtimes, linked from the main OpenXR landing
134- page at https://www.khronos.org/openxr
154+ ### Configuring the OpenXR Loader
135155
136- ## Configuring the OpenXR Loader
137- ### XR\_ RUNTIME\_ JSON environment variable
156+ On Windows and Android, the OpenXR loader is distributed with the application,
157+ not installed to the system. On Linux, the loader is available from many
158+ distributions already, and may be installed system-wide.
138159
139- The OpenXR loader looks in system-specific locations for the JSON file ` active_runtime.json ` , which describes the
140- default installed OpenXR runtime. To override the default selection, you may define an environment variable
141- ` XR_RUNTIME_JSON ` to select a different runtime, or a runtime which has not been installed in the default
142- location.
160+ #### ` XR_RUNTIME_JSON ` environment variable
143161
144- For example, you might set XR\_ RUNTIME\_ JSON to ` <build_dir>/test/runtime/my_custom_runtime.json ` to select
145- an OpenXR runtime described by JSON file ` my_custom_runtime.json ` .
162+ The OpenXR loader looks in system-specific locations for the JSON file
163+ ` active_runtime.json ` , which describes the default installed OpenXR runtime. To
164+ override the default selection, you may define an environment variable
165+ ` XR_RUNTIME_JSON ` to select a different runtime, or a runtime which has not been
166+ installed in the default location.
146167
147- ## Running the Hello_XR Test
168+ For example, you might set ` XR_RUNTIME_JSON ` to
169+ ` <build_dir>/test/runtime/my_custom_runtime.json ` to select an OpenXR runtime
170+ described by JSON file ` my_custom_runtime.json ` .
148171
149- The binary for the hello_xr application is written to the ` <build_dir>/src/tests/hello_xr ` directory.
150- Set your working directory to this directory and execute the hello_xr binary.
172+ ### Running the hello_xr Test
151173
152- ### Hello_XR with a dynamic loader (Windows)
174+ The binary for the hello_xr application is written to the
175+ ` <build_dir>/src/tests/hello_xr ` directory. Set your working directory to this
176+ directory and execute the ` hello_xr ` binary.
153177
154- When building a DLL version of the loader, the Visual Studio projects generated by CMake will copy the loader
155- DLLs to the test application's (hello_xr) binary directory. This makes it unnecessary to copy these files to someplace like ` Windows\System32 ` .
178+ ### hello_xr with a dynamic loader (Windows)
156179
180+ When building a DLL version of the loader, the Visual Studio projects generated
181+ by CMake will copy the loader DLLs to the test application's (hello_xr) binary
182+ directory.
0 commit comments