Skip to content

Conversation

@Timbals
Copy link
Contributor

@Timbals Timbals commented Jan 6, 2026

The OpenXR loader requires linking to advapi32 on Windows:
https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/58e026e7efa5a4f6a612c554560b53aa482f04d4/src/loader/CMakeLists.txt#L245

This PR adds the required linker argument.

I'm not sure why this worked before, but there was probably some other crate (or the stdlib?) linking the library.

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\Tim\\AppData\\Local\\Temp\\rustcAYV24o\\symbols.o" "<6 object files omitted>" "D:\\CargoBuild\\debug\\deps/{libopenxr-ee96c85d19891215,libopenxr_sys-8cdbb98ba39acc95,liblibc-5da270f7fc530c54}.rlib" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-*,libpanic_unwind-*,libcfg_if-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libunwind-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "legacy_stdio_definitions.lib" "kernel32.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:D:\\CargoBuild\\debug\\build\\openxr-sys-6e14873f59785b3d\\out\\lib" "/OUT:D:\\CargoBuild\\debug\\deps\\xr_link.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libstd.natvis"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_OpenProcessToken referenced in function "public: __cdecl <lambda_12e455d2ee233cf18cd2942c5feb4857>::operator()(void)const " (??R<lambda_12e455d2ee233cf18cd2942c5feb4857>@@QEBA@XZ)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_GetSidSubAuthority referenced in function "public: __cdecl <lambda_12e455d2ee233cf18cd2942c5feb4857>::operator()(void)const " (??R<lambda_12e455d2ee233cf18cd2942c5feb4857>@@QEBA@XZ)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_GetSidSubAuthorityCount referenced in function "public: __cdecl <lambda_12e455d2ee233cf18cd2942c5feb4857>::operator()(void)const " (??R<lambda_12e455d2ee233cf18cd2942c5feb4857>@@QEBA@XZ)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_GetTokenInformation referenced in function "public: __cdecl <lambda_12e455d2ee233cf18cd2942c5feb4857>::operator()(void)const " (??R<lambda_12e455d2ee233cf18cd2942c5feb4857>@@QEBA@XZ)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_RegCloseKey referenced in function "void __cdecl ReadRuntimeDataFilesInRegistry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &)" (?ReadRuntimeDataFilesInRegistry@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AEAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@@Z)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_RegEnumValueW referenced in function "public: __cdecl <lambda_617ecc765ffd261379f0e106b0d7792d>::operator()(struct HKEY__ *)const " (??R<lambda_617ecc765ffd261379f0e106b0d7792d>@@QEBA@PEAUHKEY__@@@Z)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_RegOpenKeyExW referenced in function "void __cdecl ReadRuntimeDataFilesInRegistry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &)" (?ReadRuntimeDataFilesInRegistry@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AEAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@@Z)␍
          libopenxr_sys-8cdbb98ba39acc95.rlib(manifest_file.obj) : error LNK2019: unresolved external symbol __imp_RegGetValueW referenced in function "void __cdecl ReadRuntimeDataFilesInRegistry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &)" (?ReadRuntimeDataFilesInRegistry@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AEAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@@Z)␍
          D:\CargoBuild\debug\deps\xr_link.exe : fatal error LNK1120: 8 unresolved externals␍


error: could not compile `xr_link` (bin "xr_link") due to 1 previous error

Copy link
Owner

@Ralith Ralith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I particularly appreciate the cite. This may have gone unnoticed for long periods because I tend to favor dynamic linking, which is less prone to these problems.

@Ralith Ralith merged commit 193b76a into Ralith:master Jan 7, 2026
6 checks passed
@Ralith
Copy link
Owner

Ralith commented Jan 7, 2026

Are we missing some CI coverage for this case? A fix there to prevent a future regression would be much appreciated.

@Timbals
Copy link
Contributor Author

Timbals commented Jan 7, 2026

#10 seems to suggest the static feature isn't tested in CI

@Timbals Timbals deleted the fix-windows-link-error branch January 7, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants