Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openxr_loader dll name on Windows #528

Open
madebr opened this issue Jan 23, 2025 · 5 comments
Open

openxr_loader dll name on Windows #528

madebr opened this issue Jan 23, 2025 · 5 comments
Labels
synced to gitlab Synchronized to OpenXR internal GitLab

Comments

@madebr
Copy link

madebr commented Jan 23, 2025

Hello!

There is currently an openxr PR active at libsdl-org/SDL adding openxr support.
It has support for loading openxr dynamically using LoadLibrary on Windows and dlopen on other platforms (instead of linking against the library).

However, on Windows the name of the shared library is slightly different when building a debug binary. This happens here.
Clearly, openxr_loader.dll (without d suffix) is the preferred name, but there is concern (vcpkg) package users will get non-functioning openxr SDL support because of this.
The suffix is configurable, but package maintainers are often hesitant to change default: developers have them for a reason.

Is the d suffix still required?
Current CMake Visual Studio generators put the various configurations in different folders.

@rpavlik
Copy link
Contributor

rpavlik commented Jan 23, 2025

Mixing DLLs built with the two different C runtimes is very prone to issues on Windows, which is why libraries tend to decorate their debug DLLs accordingly. I have not tested mixing a debug openxr_loader with a release (or relwithdebinfo) application, I simply assumed it did not work.

@Beyley
Copy link

Beyley commented Jan 23, 2025

I have not tested mixing a debug openxr_loader with a release (or relwithdebinfo) application, I simply assumed it did not work.

I've been mixing and matching them when doing my testing on Windows (my game's Windows builds I cross compile from my linux host as relwithdebinfo [well, the equivalent in my build system], but on my Windows test system I use a re-named debug openxr_loaderd.dll with that build). Given this is all a raw C ABI with no C++ ABI happening, as long as the respective runtimes for both debug/release are installed on the system, it does seem to work correctly.

@madebr
Copy link
Author

madebr commented Jan 23, 2025

Mixing C runtimes is only an issue with MSVC. MingW does not have this.
If openxr_loader is built as a shared library and if the openxr API does not expose any libc or stl data types (it does not), then you can happily mix different runtimes. Static libraries are trouble, but I think they can be ignored here.
Also, building with Debug CMake build type does not automatically mean a debug runtime, CMake has MSVC_RUNTIME_LIBRARY)

@rpavlik
Copy link
Contributor

rpavlik commented Jan 23, 2025

yes, I'm aware of MSVC_RUNTIME_LIBRARY though it came out after we first released this. There's also if you build the library as static or dynamic, as well as whether you use a static or dynamic C runtime... All this stuff is a mess (but only with MSVC).

Can you just try loading the "d" suffixed one as a fallback if the regular one is missing and you're on Windows? (if it does actually work...)

Yes, the idea is that it only exposes super simple types through a C api is the point, but I am not confident in that to say without testing that it's ok to mix CRT's between the lib and the app.

@rpavlik-bot
Copy link
Collaborator

An issue (number 2444) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#2444 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

@rpavlik-bot rpavlik-bot added the synced to gitlab Synchronized to OpenXR internal GitLab label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
synced to gitlab Synchronized to OpenXR internal GitLab
Projects
None yet
Development

No branches or pull requests

4 participants