btzy / nativefiledialog-extended

Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows: shell32.lib necessary, but not documented in Readme?

sschnug opened this issue · comments

When trying to get the demo (1.0 release) working using windows, msvc, bazel (using rules_foreign_cc as wrapper), i observed the following error:

ERROR: D:/code/cbs_gui/playground/BUILD:10:10: Linking playground/file_dialog.exe failed: (Exit 1120): link.exe failed: error executing command C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\link.exe @bazel-out/x64_windows-dbg/bin/playground/file_dialog.exe-2.params
nfd.lib(nfd_win.cpp.obj) : error LNK2019: unresolved external symbol __imp_SHCreateItemFromParsingName referenced in function "enum nfdresult_t __cdecl `anonymous namespace'::SetDefaultPath(struct IFileDialog *,wchar_t const *)" (?SetDefaultPath@?A0xc5579a01@@YA?AW4nfdresult_t@@PEAUIFileDialog@@PEB_W@Z)
bazel-out\x64_windows-dbg\bin\playground\file_dialog.exe : fatal error LNK1120: 1 unresolved externals

This was fixed by linking also against shell32.lib:

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

cmake(
    name = "nativefiledialog",
    lib_source = "@nativefiledialog//:all_srcs",
    lib_name = 'nfd',
    visibility = ["//visibility:public"],
    linkopts = [
      "-DEFAULTLIB:ole32.lib",
      "-DEFAULTLIB:uuid.lib",
# FIX
      "-DEFAULTLIB:shell32.lib"
    ]
)

Maybe the Readme is missing to declare this dependency?

Thanks! I think you're correct. I'll update the readme.