Building test fails on Linux
Hello,
During test compilation ('make' step) I get a lot of errors for undefined types like:
In file included from /home/adi/OpenXR-Hpp/build/include/openxr/openxr.hpp:174,
from /home/adi/OpenXR-Hpp/tests/a.cpp:2:
/home/adi/OpenXR-Hpp/build/include/openxr/openxr_dispatch_static.hpp:710:98: error: ‘XrApiLayerCreateInfo’ does not name a type; did you mean ‘XrActionSetCreateInfo’?
Please see the attached file:
I've tried Fedora 42 and clean Ubuntu 22.04 LTS installation (OpenXR-SDK, OpenXR-Source-SDK and OpenXR-Hpp from git). The log is from the Ubuntu installation:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
Hello,
I got the same error in my own code. I solved this by including the file <openxr/openxr_loader_negotiation.h> before <openxr/openxr.hpp>. You should do the same in the test source files.
Thank you for the tip. Unfortunately it changes nothing for me.
Hello,
I've take few difficulties to prepare the test environment on the OpenXR-HPP library, but now I can compile the test code. So, for the first errors, you should also enable the extension prototype functions definition.
The a.cpp file should be :
#define XR_EXTENSION_PROTOTYPES 1
#include <openxr/openxr_loader_negotiation.h>
#include "openxr/openxr.hpp"
#include "xr_dependencies.h"
static xr::DispatchLoaderDynamic xr_dispatch{};
This fix the two first errors about the XrApiLayerCreateInfo/::xrApiLayerCreateInfo definitions.
But other errors occurs.
Regards Antoine
Next error is :
[ 28%] Built target generate_headers
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_handles.hpp:87,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:176,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:3:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp:10435:5: error: expected identifier before numeric constant
10435 | 4X450 = XR_MARKER_ARUCO_DICT_4X4_50_ML,
| ^~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp:10435:5: error: expected ‘}’ before numeric constant
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp:10433:39: note: to match this ‘{’
10433 | enum class MarkerArucoDictML: int32_t {
and
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp: In function ‘const char* to_string_literal(SpatialMarkerArucoDictEXT)’:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp:20593:41: error: expected unqualified-id before numeric constant
20593 | case SpatialMarkerArucoDictEXT::4X450:
| ^~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp:20593:39: error: expected ‘:’ before numeric constant
20593 | case SpatialMarkerArucoDictEXT::4X450:
| ^ ~~~~~
| :
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_enums.hpp:20593:41: error: unable to find numeric literal operator ‘operator""X450’
20593 | case SpatialMarkerArucoDictEXT::4X450:
| ^~~~~
this is caused by a definition that include numeric value as the attribut value, in the MarkerArucoDictML extension 👍
typedef enum XrMarkerArucoDictML {
XR_MARKER_ARUCO_DICT_4X4_50_ML = 0,
XR_MARKER_ARUCO_DICT_4X4_100_ML = 1,
XR_MARKER_ARUCO_DICT_4X4_250_ML = 2,
XR_MARKER_ARUCO_DICT_4X4_1000_ML = 3,
XR_MARKER_ARUCO_DICT_5X5_50_ML = 4,
XR_MARKER_ARUCO_DICT_5X5_100_ML = 5,
XR_MARKER_ARUCO_DICT_5X5_250_ML = 6,
XR_MARKER_ARUCO_DICT_5X5_1000_ML = 7,
XR_MARKER_ARUCO_DICT_6X6_50_ML = 8,
XR_MARKER_ARUCO_DICT_6X6_100_ML = 9,
XR_MARKER_ARUCO_DICT_6X6_250_ML = 10,
XR_MARKER_ARUCO_DICT_6X6_1000_ML = 11,
XR_MARKER_ARUCO_DICT_7X7_50_ML = 12,
XR_MARKER_ARUCO_DICT_7X7_100_ML = 13,
XR_MARKER_ARUCO_DICT_7X7_250_ML = 14,
XR_MARKER_ARUCO_DICT_7X7_1000_ML = 15,
XR_MARKER_ARUCO_DICT_MAX_ENUM_ML = 0x7FFFFFFF
} XrMarkerArucoDictML;
the OpenXR-HPP create a attributs values list by splitting the enum after the XR_MARKER_ARUCO_DICT, causing nnumeric value name. This should be adapted.
Meaning while, if this extension is not used it can be disabled using 👍
#undef XR_ML_marker_understanding
before #include "openxr/openxr.hpp"
We got another numeric enum problem with another extension, so adding a
#undef XR_EXT_spatial_marker_tracking
before #include "openxr/openxr.hpp"
Now we got duplicated case :
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_handles.hpp:88,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:176,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:5:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_exceptions.hpp: In function ‘void xr::exceptions::throwResultException(xr::Result, const char*)’:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_exceptions.hpp:2602:9: error: duplicate case value
2602 | case Result::ErrorExtensionDependencyNotEnabledKHR:
| ^~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_exceptions.hpp:2162:9: note: previously used here
2162 | case Result::ErrorExtensionDependencyNotEnabled:
| ^~~~
this seems normal :
../../OpenXR-Hpp/include/openxr/openxr_enums.hpp: ErrorExtensionDependencyNotEnabled = XR_ERROR_EXTENSION_DEPENDENCY_NOT_ENABLED,
../../OpenXR-Hpp/include/openxr/openxr_enums.hpp: ErrorExtensionDependencyNotEnabledKHR = XR_ERROR_EXTENSION_DEPENDENCY_NOT_ENABLED_KHR,
../../OpenXR-Hpp/include/openxr/openxr_enums.hpp: case Result::ErrorExtensionDependencyNotEnabled:
../../OpenXR-Hpp/include/openxr/openxr_enums.hpp: return "ErrorExtensionDependencyNotEnabled";
../../OpenXR-Hpp/include/openxr/openxr_enums.hpp: // ErrorExtensionDependencyNotEnabledKHR is an alias for ErrorExtensionDependencyNotEnabled
and
./../OpenXR-SDK-Source/build/linux_debug/include/openxr/openxr.h: XR_ERROR_EXTENSION_DEPENDENCY_NOT_ENABLED = -1000710001,
../../OpenXR-SDK-Source/build/linux_debug/include/openxr/openxr.h: XR_ERROR_EXTENSION_DEPENDENCY_NOT_ENABLED_KHR = XR_ERROR_EXTENSION_DEPENDENCY_NOT_ENABLED,
in this case the ErrorExtensionDependencyNotEnabledKHR come from the XR_KHR_maintenance1 extension, that add retro-compatibility definitions/functions from OpenXR 1.0 to OpenXR 1.1.
This extension can be disabled using :
#undef XR_KHR_maintenance1
before #include "openxr/openxr.hpp"
But it may cause other errors if this extension is used for old application/test code.
Next :
[29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:176,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:6:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_handles.hpp:11061:5: error: ‘FutureEXT’ does not name a type; did you mean ‘XrFutureEXT’?
11061 | FutureEXT createSpatialAnchorsAsyncML (
| ^~~~~~~~~
| XrFutureEXT
Watching the OpenXR Registry in ../../OpenXR-SDK-Source/specification/registry/xr.xml, XrFutureEXT description is :
<!-- Non-handle 64-bit opaque type from XR_EXT_future -->
<type category="basetype"><type>XR_DEFINE_OPAQUE_64</type>(<name>XrFutureEXT</name>)</type>
and this is the only XR_DEFINE_OPAQUE_64 item :
#if !defined(XR_DEFINE_OPAQUE_64)
#if (XR_PTR_SIZE == 8)
#define <name>XR_DEFINE_OPAQUE_64</name>(object) typedef struct object##_T* object;
#else
#define XR_DEFINE_OPAQUE_64(object) typedef uint64_t object;
#endif
#endif</type>
I suspect that this case is not managed by the OpenXR-HPP parser.
A workaround is to define an alias before #include openxr.hpp with :
using FutureEXT = XrFutureEXT;
Regards
Next :
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:7:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:8465:47: error: static assertion failed: Original type and wrapper have different size!
8465 | static_assert(sizeof(XrApiLayerNextInfo) == sizeof(ApiLayerNextInfo), "Original type and wrapper have different size!");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:8465:47: note: the comparison reduces to ‘(296 == 288)’
This time the last 'next' member of the XrApiLayerNextInfo is not present in the HPP class.
It seems that the parsing has trouble bacause there are many next... members and the last one it 'next'' only, and is so not generated in the final class. If this member is renamed 'nextInfo' in the registry ../../OpenXR-SDK-Source/specification/registry/xr.xml it's working (but the structure is then not the correct one according to the API documentation) :
from :
<type category="struct" name="XrApiLayerNextInfo">
<member><type>XrLoaderInterfaceStructs</type> <name>structType</name></member>
<member><type>uint32_t</type> <name>structVersion</name></member>
<member><type>size_t</type> <name>structSize</name></member>
<member><type>char</type> <name>layerName</name>[<enum>XR_MAX_API_LAYER_NAME_SIZE</enum>]</member>
<member><type>PFN_xrGetInstanceProcAddr</type> <name>nextGetInstanceProcAddr</name></member>
<member><type>PFN_xrCreateApiLayerInstance</type> <name>nextCreateApiLayerInstance</name></member>
<member>struct <type>XrApiLayerNextInfo</type>* <name>next</name></member>
</type>
to :
<type category="struct" name="XrApiLayerNextInfo">
<member><type>XrLoaderInterfaceStructs</type> <name>structType</name></member>
<member><type>uint32_t</type> <name>structVersion</name></member>
<member><type>size_t</type> <name>structSize</name></member>
<member><type>char</type> <name>layerName</name>[<enum>XR_MAX_API_LAYER_NAME_SIZE</enum>]</member>
<member><type>PFN_xrGetInstanceProcAddr</type> <name>nextGetInstanceProcAddr</name></member>
<member><type>PFN_xrCreateApiLayerInstance</type> <name>nextCreateApiLayerInstance</name></member>
<member>struct <type>XrApiLayerNextInfo</type>* <name>nextInfo</name></member>
</type>
and regenerate the .hpp file from the OpenXR-HPP project, fix this problem (but I also rename back ApiLayerNextInfo::nextInfo to ApiLayerNextInfo::next in ../include/openxr/openxr_structs.hpp)
Regards
Next :
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:7:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp: In constructor ‘xr::CompositionLayerPassthroughFB::CompositionLayerPassthroughFB(const xr::CompositionLayerFla
gs&, const xr::Space&, const xr::PassthroughLayerFB&, const void*)’:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:24887:28: error: no matching function for call to ‘xr::CompositionLayerBaseHeader::CompositionLayerBaseHeader(xr::StructureType, const xr::Space&, const void*&)’
24887 | , layerHandle {layerHandle_}
| ^
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:3541:17: note: candidate: ‘xr::CompositionLayerBaseHeader::CompositionLayerBaseHeader(xr::StructureType, const xr::CompositionLayerFlags&, const xr::Space&, const void*)’
3541 | CompositionLayerBaseHeader (
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:3542:55: note: no known conversion for argument 2 from ‘const xr::Space’ to ‘const xr::CompositionLayerFlags&’ {aka ‘const xr::Flags<xr::CompositionLayerFlagBits, long unsigned int>&’}
3542 | StructureType type_ , const CompositionLayerFlags& layerFlags_, const Space& space_, const void * next_ = nullptr )
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:3535:25: note: candidate: ‘constexpr xr::CompositionLayerBaseHeader::CompositionLayerBaseHeader(const xr::CompositionLayerBaseHeader&)’
3535 | struct XR_MAY_ALIAS CompositionLayerBaseHeader : public impl::InputStructBase
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:3535:25: note: candidate expects 1 argument, 3 provided
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:3535:25: note: candidate: ‘constexpr xr::CompositionLayerBaseHeader::CompositionLayerBaseHeader(xr::CompositionLayerBaseHeader&&)’
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:3535:25: note: candidate expects 1 argument, 3 provided
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp: At global scope:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:24943:60: error: static assertion failed: Original type and wrapper have different size!
24943 | static_assert(sizeof(XrCompositionLayerPassthroughFB) == sizeof(CompositionLayerPassthroughFB), "Original type and wrapper have different size!");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the registry we can see that XrCompositionLayerPassthroughFB "extends" (using parentstruct) CompositionLayerBaseHeader but the derivated class doesn't call the constructor with the parameters in the right order; this caused by the third base parameter which is not the same name as the parent class (flags vs layerFlags).
I also see that there are many CompositionLayerBaseHeader derivated structures with the same problems.
So there are two workaround :
- disable this extension using
#undef XR_FB_passthrough
#undef XR_META_passthrough_layer_resumed_event
#undef XR_META_passthrough_color_lut
I'm working on Quest headset , so I would prefer the second option, but for the OpenXR-HPP test compilation I use the first.
Regards
Ordering problem with :
29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:8:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:29533:67: error: invalid use of incomplete type ‘struct xr::FutureCompletionBaseHeaderEXT’
29533 | struct XR_MAY_ALIAS CreateSpatialAnchorsCompletionML : public FutureCompletionBaseHeaderEXT
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_handles.hpp:91,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:176:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs_forward.hpp:598:8: note: forward declaration of ‘struct xr::FutureCompletionBaseHeaderEXT’
598 | struct FutureCompletionBaseHeaderEXT;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
where the class FutureCompletionBaseHeaderEXT is not fully defined before the CreateSpatialAnchorsCompletionML class, because the XR_ML_spatial_anchors extension (number=141) depends on the XR_EXT_future extension (number=470) and the Registry API parser sort the extensions by number.
Let's try to disable this extension 👍
#undef XR_ML_spatial_anchors #undef XR_ML_spatial_anchors_storage
Regards
Other error :
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:11:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp: In constructor ‘xr::EnvironmentDepthImageMETA::EnvironmentDepthImageMETA(uint32_t, float, float, const xr::EnvironmentDepthImageViewMETA&, const void*)’:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:44592:27: error: cannot convert ‘const xr::EnvironmentDepthImageViewMETA’ to ‘const void*’
44592 | memcpy(views, views_, sizeof(views));
| ^~~~~~
| |
| const xr::EnvironmentDepthImageViewMETA
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:105:
/usr/include/string.h:43:70: note: initializing argument 2 of ‘void* memcpy(void*, const void*, size_t)’
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
The memcpy second parameter call views_ is neither an address nor an array, it' a reference :
const EnvironmentDepthImageViewMETA& views_
but in the registry it' defined as an array of two items :
<type category="struct" name="XrEnvironmentDepthImageMETA">
<member values="XR_TYPE_ENVIRONMENT_DEPTH_IMAGE_META"><type>XrStructureType</type> <name>type</name></member>
<member>const <type>void</type>* <name>next</name></member>
<member><type>uint32_t</type> <name>swapchainIndex</name></member>
<member><type>float</type> <name>nearZ</name></member>
<member><type>float</type> <name>farZ</name></member>
<member><type>XrEnvironmentDepthImageViewMETA</type> <name>views</name>[2]</member>
</type>
and the class member target views is correct :
EnvironmentDepthImageViewMETA views[2];
So this only problem is the class contructor parameter. We could modify the memcpy call to use &views_ but the sizeof(views_) need to be changed too.
So the now workaround is to disable this extension with #undef XR_META_environment_depth.
Next :
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:12:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:51814:61: error: invalid use of incomplete type ‘struct xr::FutureCompletionBaseHeaderEXT’
51814 | struct XR_MAY_ALIAS SenseDataQueryCompletionBD : public FutureCompletionBaseHeaderEXT
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_handles.hpp:91,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:176:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs_forward.hpp:598:8: note: forward declaration of ‘struct xr::FutureCompletionBaseHeaderEXT’
598 | struct FutureCompletionBaseHeaderEXT;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp: In constructor ‘xr::SenseDataQueryCompletionBD::SenseDataQueryCompletionBD(void*)’:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:51823:3: error: type ‘xr::FutureCompletionBaseHeaderEXT’ is not a direct base of ‘xr::SenseDataQueryCompletionBD’
is another class ordering problem with Future* class.
Workaround :
#undef XR_BD_spatial_scene
#undef XR_BD_spatial_sensing
#undef XR_BD_spatial_anchor
#undef XR_BD_spatial_anchor_sharing
So now a.cpp compiles successfully.
But, off course, the same errors appear when compiling the other source files ({b,c,d,e,f,flags...}.cpp).
I've created a tofix.h source file in the same directory as a.cpp (../tests/tofix.cpp from the build directory) :
#undef XR_NO_PROTOTYPES
#define XR_EXTENSION_PROTOTYPES 1
#include <openxr/openxr_loader_negotiation.h>
#undef XR_KHR_maintenance1
#undef XR_EXT_spatial_marker_tracking
#undef XR_FB_passthrough
#undef XR_FB_passthrough_keyboard_hands
#undef XR_META_passthrough_color_lut
#undef XR_META_passthrough_layer_resumed_event
#undef XR_META_environment_depth
#undef XR_ML_marker_understanding
#undef XR_ML_spatial_anchors
#undef XR_ML_spatial_anchors_storage
#undef XR_BD_spatial_scene
#undef XR_BD_spatial_sensing
#undef XR_BD_spatial_anchor
#undef XR_BD_spatial_anchor_sharing
using FutureEXT = XrFutureEXT;
and I include it before any #include "openxr/openxr.hpp in all the sources; I've also include this file in few generated test source files like ./tests/buildcleanly_openxr_dispatch_static.cpp (#include "../../tests/tofix.h")
=> all the test compile and link.
==> but of course, all this is just a dirty workaround, and the real problems should be solved to make the OpenXR-HPP fully functionnal with all the extensions ==> TO DO
One thing I've noticed, OpenXR-Hpp and OpenXR versions have to match (no forward compatibility?). If I use version 1.0.26 from tarballs OpenXR-Hpp-release-1.0.26.tar.gz OpenXR-SDK-Source-release-1.0.26.tar.gz everything builds correctly.
Seems logic, but 1.0.26 is the last published OpenXR-HPP tag, and I use the last 1.1.49 OpenXR-SDK.
I start a fork to fix theses problems : https://github.com/antoineemerit/OpenXR-Hpp/
Now, the test app compiles and links successfully using my fork.
I'm starting to use Open-HPP in my Meta Quest application (based on the OpenXR SDK HelloXR app).
Now, the test app compiles and links successfully using my fork.
Can confirm. Compiles fine with OpenXR 1.1.49. Thank you.
1.1.50 and git fails for me with:
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/adi/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/adi/OpenXR-Hpp/tests/a.cpp:2:
/home/adi/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:49985:54: error: static assertion failed: Original type and wrapper have different size!
49985 | static_assert(sizeof(XrRaycastHitResultANDROID) == sizeof(RaycastHitResultANDROID), "Original type and wrapper have different size!");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [tests/CMakeFiles/a.dir/build.make:76: tests/CMakeFiles/a.dir/a.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:965: tests/CMakeFiles/a.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
I am leaving this issue open, as KhronosGroup maintainers should see the pattern here. Manually fixing OpenXR-HPP after every single SDK release does not seem to be a viable solution.
For this error, and if you are not using Android raycasting, I suggest you to disable the XR_ANDROID_raycast extensions, by adding its name in the OpenXR-Hpp/scripts/data.py file (EXCLUDED_EXTENSIONS parameter).
Meaning while, I continue to work on the OpenXr-HPP scripts to re-enabled the disabled extensions I'm using (Meta Passthrough...), and this should fix other extensions at the same time.
I'll keep you in touch in this issue.
After fixing the struct hierarchy, I get another error :
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_method_impls.hpp:98,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:183,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:2:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_method_impls_enhanced_exceptions.inl: In member function ‘xr::SpatialEntityComponentDataBaseHeaderBD xr::SenseDataSnapshotB
D::getSpatialEntityComponentDataBD(const xr::SpatialEntityComponentGetInfoBD&, Dispatch&&) const’:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_method_impls_enhanced_exceptions.inl:16718:131: error: no matching function for call to ‘put(xr::SpatialEntityComponentData
BaseHeaderBD&)’
16718 | Result result = static_cast<Result>( d.xrGetSpatialEntityComponentDataBD(this->get(), getInfo.get(), OPENXR_HPP_NAMESPACE::put(componentData)) );
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:171:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:404:38: note: candidate: ‘XrSystemId* xr::put(SystemId&, bool)’
404 | static OPENXR_HPP_INLINE XrSystemId *put(SystemId &v, bool clear = true) noexcept { return v.put(clear); }
| ^~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:404:52: note: no known conversion for argument 1 from ‘xr::SpatialEntityComponentDataBaseHeaderBD’ to ‘xr::Syst
emId&’
404 | static OPENXR_HPP_INLINE XrSystemId *put(SystemId &v, bool clear = true) noexcept { return v.put(clear); }
| ~~~~~~~~~~^
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:613:34: note: candidate: ‘XrPath* xr::put(Path&, bool)’
613 | static OPENXR_HPP_INLINE XrPath *put(Path &v, bool clear = true) noexcept { return v.put(clear); }
| ^~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:613:44: note: no known conversion for argument 1 from ‘xr::SpatialEntityComponentDataBaseHeaderBD’ to ‘xr::Path
&’
613 | static OPENXR_HPP_INLINE XrPath *put(Path &v, bool clear = true) noexcept { return v.put(clear); }
| ~~~~~~^
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:822:46: note: candidate: ‘XrAsyncRequestIdFB* xr::put(AsyncRequestIdFB&, bool)’
822 | static OPENXR_HPP_INLINE XrAsyncRequestIdFB *put(AsyncRequestIdFB &v, bool clear = true) noexcept { return v.put(clear); }
| ^~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:822:68: note: no known conversion for argument 1 from ‘xr::SpatialEntityComponentDataBaseHeaderBD’ to ‘xr::Asyn
cRequestIdFB&’
822 | static OPENXR_HPP_INLINE XrAsyncRequestIdFB *put(AsyncRequestIdFB &v, bool clear = true) noexcept { return v.put(clear); }
| ~~~~~~~~~~~~~~~~~~^
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_atoms.hpp:1031:46: note: candidate: ‘XrRenderModelKeyFB* xr::put(RenderModelKeyFB&, bool)’
1031 | static OPENXR_HPP_INLINE XrRenderModelKeyFB *put(RenderModelKeyFB &v, bool clear = true) noexcept { return v.put(clear); }
| ^~~
This is for the XR_BD_spatial_sensing extension.
The struct SpatialEntityComponentDataBaseHeaderBD has not put() function (member nor global), because this structure is abstract (no .type member value available in the registry). This extension uses "derivated" struct types, but the function uses pointer to this pseudo "base class" structure, and needs a put() function in this "base class".
The workaround is to disable this extension in the scripts/data.py file.
I my OpenXR-HPP fork, I fixed all the compile errors while removing all skip projection problem using the OpenXR-SDK 1.1.49
But after updating to OpenXR-SDK 1.1.50, I have the following error :
[ 28%] Built target generate_headers
[ 29%] Building CXX object tests/CMakeFiles/a.dir/a.cpp.o
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr.hpp:177,
from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/tests/a.cpp:2:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:63777:54: error: static assertion failed: Original type and wrapper have different size!
63777 | static_assert(sizeof(XrRaycastHitResultANDROID) == sizeof(RaycastHitResultANDROID), "Original type and wrapper have different size!");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-Hpp/build/include/openxr/openxr_structs.hpp:63777:54: note: the comparison reduces to ‘(48 == 56)’
make[2]: *** [tests/CMakeFiles/a.dir/build.make:76 : tests/CMakeFiles/a.dir/a.cpp.o] Erreur 1
make[1]: *** [CMakeFiles/Makefile2:965 : tests/CMakeFiles/a.dir/all] Erreur 2
make: *** [Makefile:146 : all] Erreur 2
The XrRaycastHitResultANDROID structure has a 'type' member but no 'next' member, and the projection process add a 'next' member and so the error, and the 'type' member is not based on XrStructureType and shouldn't be hidden and parent class initialized.
In fact this structure is a not derivated one.
All skiped extensions, structures and functions re-enabled, and all compilation errors fixed with the OpenXR-SDK 1.1.50 (the last one at this date) in my fork https://github.com/antoineemerit/OpenXR-Hpp/ !
Have a try and let me know if it works fine for you.
Wow, thanks for your persistent work on this! I tend to find that I never have the time I want to maintain this properly, so I really appreciate it. It's on my list to look at today - can you open an MR for easier commenting?
Before the merge request, I will test these modifications in my own code and fix other problems (two call functions...).
@antoineemerit I can confirm, works fine. Tested with OpenXR-SDK-Source form git.
I just compile the test build with the new OpenXR SDK 1.1.51 : no error !
While there is no error in compiling the test source on SDK 1.1.51, there are errors while compiling my own application (based on hello_xr source code) :
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/logger.cpp:5:
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/pch.h:129:
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr.hpp:138:
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_method_impls.hpp:64:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_method_impls_enhanced_exceptions.inl:3033:30: error: no matching constructor for initialization of 'SwapchainStateBaseHeaderFB'
3033 | SwapchainStateBaseHeaderFB state;
| ^
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_structs.hpp:16892:21: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
16892 | struct XR_MAY_ALIAS SwapchainStateBaseHeaderFB : public impl::OutputStructBase {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_structs.hpp:16892:21: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided
16892 | struct XR_MAY_ALIAS SwapchainStateBaseHeaderFB : public impl::OutputStructBase {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_structs.hpp:16898:3: note: candidate constructor not viable: requires at least argument 'type_', but no arguments were provided
16898 | SwapchainStateBaseHeaderFB(StructureType type_, void* next_ = nullptr) : Parent(type_, next_) {}
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ask Gemini
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/logger.cpp:5:
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/pch.h:129:
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr.hpp:138:
In file included from /home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_method_impls.hpp:64:
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_method_impls_enhanced_exceptions.inl:8030:42: error: no matching constructor for initialization of 'SpatialEntityComponentDataBaseHeaderBD'
8030 | SpatialEntityComponentDataBaseHeaderBD componentData;
| ^
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_structs.hpp:47237:21: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
47237 | struct XR_MAY_ALIAS SpatialEntityComponentDataBaseHeaderBD : public impl::OutputStructBase {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_structs.hpp:47237:21: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided
47237 | struct XR_MAY_ALIAS SpatialEntityComponentDataBaseHeaderBD : public impl::OutputStructBase {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/antoine/AndroidStudioProjects/Bille2_VR/OpenXR-SDK-Source-main/src/tests/hello_xr/../../../../OpenXR-Hpp/include/openxr/openxr_structs.hpp:47243:3: note: candidate constructor not viable: requires at least argument 'type_', but no arguments were provided
47243 | SpatialEntityComponentDataBaseHeaderBD(StructureType type_, void* next_ = nullptr)
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ask Gemini
There errors as causeb by base strcutures that don't defined a default value for the 'type' (XsStructureType) member. But the real problem is that the implied enhanced functions create and return a local element of these base structures. It should be a derivated structure which is impossible to know in theses case because the function don't take the structure element has an input.
This is a general problem which all the structures that are used as an (partial) input and output, in which case these structure should be send unmodified to these functions.
For now the workaround is to disabled theses functions or the maching extensions,
in the scripts/data/py :
EXCLUDED_EXTENSIONS = (
"XR_BD_spatial_sensing",
"XR_FB_swapchain_update_state",
"XR_FB_swapchain_update_state_android_surface",
"XR_FB_swapchain_update_state_opengl_es",
"XR_FB_swapchain_update_state_vulkan",
"XR_FB_foveation",
"XR_FB_foveation_vulkan",
)
=> fixed in my fork by disabling enhanced functions that use base_only structure pointer.
New improvement in my fork : disable structure returned functions (and fix clearing) where structure needs and application allocation for some members. This reduce the enhanced functions but make the basic functions (with exception) functionnal.
Hi,
I think, I have fixed all remaining problems in my fork (two call method, pointer of pointer, atom as output...). I have also aligned types and methods projection for remaining types (enum, atoms, Bool32, FutureEXT, native C, alias...).
While I'm using the OpenXR-Hpp in my own project (on Meta Oculus Quest 3 and Quest Pro), feedbacks are welcome.
Regards