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

undefined symbol: SHGetKnownFolderPath, when compile code with clang target=x86_64-pc-windows-msvc #440

Open
denchat opened this issue Apr 26, 2019 · 2 comments

Comments

@denchat
Copy link

denchat commented Apr 26, 2019

I tried compile my code agaist tz.lib using clang target msvc.

lld-link: error: undefined symbol: SHGetKnownFolderPath
>>> referenced by tz.lib(tz.cpp.obj):(bool __cdecl date::remote_install(class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> const
&))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Perhaps other than -lole32 (in documentation), now tz.lib also requires -lshell32 on windows?
Is it just because that mingw64 automatically links agaist shell32.lib by default?

@HowardHinnant
Copy link
Owner

I'm not sure. I do see that SHGetKnownFolderPath is used in tz.cpp, and I note this comment:

// None of this happens with the MS SDK (at least VS14 which I tested), but:
// Compiling with mingw, we get "error: 'KF_FLAG_DEFAULT' was not declared in this scope."
// and error: 'SHGetKnownFolderPath' was not declared in this scope.".
// It seems when using mingw NTDDI_VERSION is undefined and that
// causes KNOWN_FOLDER_FLAG and the KF_ flags to not get defined.
// So we must define NTDDI_VERSION to get those flags on mingw.
// The docs say though here:
// https://msdn.microsoft.com/en-nz/library/windows/desktop/aa383745(v=vs.85).aspx
// that "If you define NTDDI_VERSION, you must also define _WIN32_WINNT."
// So we declare we require Vista or greater.

I don't have Windows to test on.

@denchat
Copy link
Author

denchat commented Apr 29, 2019

SHGetKnownFolderPath on this page
https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath

SDK API requires: Vista
defined in header: shlobj_core.h
DLL: Shell32.dll (version 6.0.6000++)

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

No branches or pull requests

2 participants