1

I am having a problem building Pathfinder 3's demo on my Windows 10 machine.

I know that someone else has been able to run the demo on Windows 10, so it is possible. However, I am running into an issue which has been difficult to troubleshoot.

I cloned the repo, and commented out the single reference to jemalloc (which does not target Win10).

To set up SDL2, I followed the instructions under header Windows (MSVC) of the Rust SDL2 readme.

To run the demo, I use the following commands via powershell, after changing into the demo/native directory:

$env:RUSTFLAGS += "-C target-cpu=native"

cargo run --release

If I do not have the SDL2 lib files under .multirust/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc, then I get an error complaining about *.lib files not being found:

fatal error LNK1181: cannot open input file 'SDL2.lib'

Putting the *.lib files into that folder fixes this issue.

If I put the SDL2.dll file in the main pathfinder folder, I get the error:

error LNK2019: unresolved external symbol __imp_SHCreateItemFromParsingName referenced in function "enum nfdresult_t __cdecl SetDefaultPath(struct IFileDialog *,char const *)"

If I put the SDL2.dll in the demo/native folder, I get the same error as above.

I have tried using the developer command prompts of VS2015, and VS2017, but with no luck. In particular, when trying to build using these prompts, I cannot use the RUSTFLAGS suggested, so I omit them.

I also tried using git bash, but the same error noted in the title occurs. What can I try next?

bzm3r
  • 3,113
  • 6
  • 34
  • 67
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Mar 21 '19 at 02:06
  • @KenWhite Thanks for linking that. I went through it, and I think this answer is the relevant one: https://stackoverflow.com/a/12574400/3486684 --- however, I still have to try to apply its fix, so let me try that out to see if it works. – bzm3r Mar 21 '19 at 02:26
  • Just FYI, the issue has nothing to do with SDL2.dll. The problem is in a missing **.lib** file. DLLs are used at runtime, and can't cause a LNK error at compile/link time. – Ken White Mar 21 '19 at 02:43
  • @KenWhite following the suggestion of the answer, I looked up the function causing an issue, without the `__imp_` prefix in MSDN: [`SHCreateItemFromParsingName function`](https://learn.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreateitemfromparsingname). But, the doc page doesn't refer to any libraries which might be missing, as the answer suggests? – bzm3r Mar 21 '19 at 02:48
  • You can find the library information in the MSDN documentation for the function. It's in Shell32.dll, which means you need the import library for Shell32. – Ken White Mar 21 '19 at 02:52
  • @KenWhite Sorry, for the silly questions, I am out of my element here. Was the page I linked to not the MSDN documentation for the function? Also, it is not clear to me how I figure out which library goes along with Shell32. I found some relevant pages for Shell32 on MSDN, but have not gotten a clear lead on what library is missing. – bzm3r Mar 21 '19 at 03:00
  • It is on that page, which was what I was pointing out. Look at the bottom, which tells you it's in Shell32.dll. That means you need the import library for Shell32, which is Shell32.lib. It's in your SDK (now called "Windows Kit") folder tree. – Ken White Mar 21 '19 at 03:04
  • Ah I see! Alright, let me see if including that library fixes issues. – bzm3r Mar 21 '19 at 03:08
  • @KenWhite I think the issue is obliquely related to `shell32.lib`. Making sure I explicitly include `shell32.lib` (i.e. by dumping it in the rust toolchain lib) causes the same error. However, someone else has reported this, and it seems to be an issue with the `nfd` crate for rust: https://github.com/saurvs/nfd-rs/issues/14 – bzm3r Mar 21 '19 at 03:14

1 Answers1

0

I recently run into a similar problem when I using tesseract-rs on windows. The tessertact library use libcurl which using two system libs User32 and Crypt32. The solution just add a build.rs and put these two lib in it.

fn main() {
    println!("cargo:rustc-link-lib=User32");
    println!("cargo:rustc-link-lib=Crypt32");
}
mtfcd
  • 1
  • 2