cvulkanopenxr

OpenXR, how to obtain xrGetInstanceProcAddr on windows, C and Vulkan


I need to get the platform-specific xrGetInstanceProcAddr, I'm on windows Visual Studio, language is C, API is vulkan.

I've got error "extern undefined symbol xrGetInstanceProcAddr" when running the following code:

#define XR_USE_PLATFORM_WIN32
#define XR_USE_GRAPHICS_API_VULKAN

#ifdef XR_USE_PLATFORM_WIN32
#include <Windows.h>
#endif

#include "../openxr/openxr.h"
#include "../openxr/openxr_platform.h"
#include "../openxr/openxr_platform_defines.h"
#include "../openxr/openxr_reflection.h"

main(int argc, char** argv)
{
    XrResult result = XR_SUCCESS;
    uint32_t ext_count = 0;

    PFN_xrEnumerateInstanceExtensionProperties qxrEnumerateInstanceExtensionProperties;
    
    result = xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrEnumerateInstanceExtensionProperties", (PFN_xrVoidFunction*)&qxrEnumerateInstanceExtensionProperties);

    result = qxrEnumerateInstanceExtensionProperties(NULL, 0, &ext_count, NULL);
}

Solution

  • The openxr loader was needed. In visual studio, nuget package manager:

    Install-Package OpenXR.Loader -Version 1.0.10.2