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

Fails to link: unresolved externals from 'pathcch.h' (Windows) #42

Closed
JasperVanEsveld opened this issue Aug 16, 2020 · 10 comments · Fixed by #43
Closed

Fails to link: unresolved externals from 'pathcch.h' (Windows) #42

JasperVanEsveld opened this issue Aug 16, 2020 · 10 comments · Fixed by #43

Comments

@JasperVanEsveld
Copy link

JasperVanEsveld commented Aug 16, 2020

Tried to build the example and another project but always get this error.
pathcch.h is part of the win32 library but I should have all the necessary build tools for c++ installed (at least I think so the SDL crate works fine for example)
This is the error:

libopenxr_sys-9008a7c2938b17d8.rlib(filesystem_utils.obj) : error LNK2019: unresolved external symbol __imp_PathCchCanonicalize referenced in function "bool __cdecl FileSysUtilsGetCanonicalPath(class std::basic_string<char,struct std::char_traits<char>,class std::allocaferenced in function "bool __cdecl FileSysUtilsGetCanonicalPath(class std::basic_string<chartor<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?FileSysUtilsGetCanonicalPalocator<char> > &)" (?FileSysUtilsGetCanonicalPath@@YA_NAEBV?$basic_string@DU?$char_traits@Dth@@YA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAV12@@Z)

Is there something I am missing?

@Ralith
Copy link
Owner

Ralith commented Aug 16, 2020

This is likely a bug on our end; thanks for the report! OpenXR 1.0.11 added a use of PathCchCanonicalize and I need to work out what incantation is necessary to make rust link the definition.

@Ralith
Copy link
Owner

Ralith commented Aug 16, 2020

Would you mind testing #43?

@JasperVanEsveld
Copy link
Author

Thanks for the quick reply!
But sadly it doesn't seem to work for me, get the same error :(
Can you reproduce it? Might be my setup...

@JasperVanEsveld
Copy link
Author

Just checked some older versions and 0.11.0 seems to work, might be because it uses an older OpenXR version
Thought that might be useful to know

@VZout
Copy link

VZout commented Aug 17, 2020

Thanks for the quick reply!
But sadly it doesn't seem to work for me, get the same error :(
Can you reproduce it? Might be my setup...

I'm also running into this issue.

@Ralith
Copy link
Owner

Ralith commented Aug 17, 2020

Thanks for the report. The call was added in OpenXR 1.0.11, so older versions of openxrs, which use older versions of the OpenXR loader, should work fine; I recommend rolling back to those until I have time to dig into this further, which should be within the week, unless someone else is able to investigate and make a PR.

@Ralith
Copy link
Owner

Ralith commented Aug 23, 2020

Got some time to test this on my windows box and, oddly, master works just fine for me:

C:\Users\Ralith\src\openxrs\openxr [master ≡]> cargo run --example vulkan --features static
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `C:\Users\Ralith\src\openxrs\target\debug\examples\vulkan.exe`
loaded OpenXR runtime: SteamVR/OpenXR 0.1.0

What version of MSVC are you using?

@JasperVanEsveld
Copy link
Author

Hmm that's interesting...
I am using MSVC v142 (v14.27)

@Ralith
Copy link
Owner

Ralith commented Aug 23, 2020

Had an inverted condition in the first draft of the fix; should work fine now. Published openxr-sys 0.8.4 with the fix.

@tilkinsc
Copy link

tilkinsc commented Jan 12, 2021

I'm running into issues with building with openxr itself. It appears that the symbol for PathCchCanonicalize isn't anywhere to be found on builds that are outside of MSVS. It appears you need a compiler that is newer than about 7.1ish with mingw. It apparently is in C:\Windows\System32\api-ms-core-path...dll, however, 1.) a lot of users are missing this on their systems, 2.) people using other compilers such as mingw64 don't directly have a reference to it yet as it should be something in libstdc++fs (its experiemental, ack why do you do this) However, you can just piggyback off a lot of windows native dlls because they INCLUDE the reference to it. It is in Pathcch.lib and its a static library.

Timbals added a commit to Timbals/openxrs that referenced this issue Jul 16, 2024
The build script used the `cfg!` macro to check the target os, but the "target" in a build script is actually the host.
Use the `CARGO_CFG_TARGET_OS` environment variable instead.

Issue Ralith#42 [has been worked around](KhronosGroup/OpenXR-SDK-Source#198),
and then [fixed upstream](KhronosGroup/OpenXR-SDK-Source#239),
so the additional flag on windows is no longer necessary.

Linking the filesystem library is also done correctly upstream now:
https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/main/src/cmake/StdFilesystemFlags.cmake
Timbals added a commit to Timbals/openxrs that referenced this issue Jul 16, 2024
The build script used the `cfg!` macro to check the target os, but the "target" in a build script is actually the host.
Use the `CARGO_CFG_TARGET_OS` environment variable instead.

Issue Ralith#42 [has been worked around](KhronosGroup/OpenXR-SDK-Source#198),
and then [fixed upstream](KhronosGroup/OpenXR-SDK-Source#239),
so the additional flag on windows is no longer necessary.

Linking the filesystem library is also done correctly upstream now:
https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/main/src/cmake/StdFilesystemFlags.cmake
Ralith pushed a commit that referenced this issue Jul 18, 2024
The build script used the `cfg!` macro to check the target os, but the "target" in a build script is actually the host.
Use the `CARGO_CFG_TARGET_OS` environment variable instead.

Issue #42 [has been worked around](KhronosGroup/OpenXR-SDK-Source#198),
and then [fixed upstream](KhronosGroup/OpenXR-SDK-Source#239),
so the additional flag on windows is no longer necessary.

Linking the filesystem library is also done correctly upstream now:
https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/main/src/cmake/StdFilesystemFlags.cmake
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 a pull request may close this issue.

4 participants