Open nouritsu opened 1 year ago
After some fiddling I think I can reproduce this in a Windows 10 VM:
PS C:\Users\anon\Desktop\project> cargo build
Compiling magic-sys v0.3.0 (C:\Users\anon\Desktop\rust-magic-sys)
Compiling thiserror-impl v1.0.47
Compiling thiserror v1.0.47
Compiling magic v0.13.0
Compiling project v0.1.0 (C:\Users\anon\Desktop\project)
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\anon\\AppData\\Local\\Temp\\rustcUPaWBo\\symbols.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.18k7v26q6k3nuzfa.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.1ba5xpyci7cyj002.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.1bfhrxkn6f9hgnha.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.1c7065kdn4fun3os.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.1rf8k80ilsa4aqqb.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.1vrbqq568yb03s5j.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.1ybw15o654z4nupk.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.27x24l1ea5ntnkdk.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.2b0jzxu07wgama8q.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.2b67wkzkd8vosjg1.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.2rf31zlfxtud9p8r.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.2tthl9e1pji8i9bk.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.30pqak9xocnwcour.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.312tg5xe4kfnj2no.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.3az2evtq7xl7j1xf.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.3h88ejvyfa7wj6ng.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.3mz0fsuap4qsrg2p.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.3x5tq2gpibxumeto.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.47dg6j11y4ro56xz.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.4857j1lk6juydddu.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.4988gudz77fs6a3c.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.498bi8ck0rg5fhj5.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.4ex7530k2ow9z6d3.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.4h3t0x9qr24t2uas.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.4npinqio8kso9tta.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.4s94zejz2nsqfoks.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.58h1eghnaiyzltqn.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.5b3fpmlwlcqc1bn4.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.5brlyvgxvp8ggvbn.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.5fgnq7i6d6ul6h77.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.5fmyebqtye5145ru.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.6iirh65760odrn4.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.d6lez2bl9um2h2s.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.go6fina1ctfujq1.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.m2cd2155938tjwg.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.mlzgdryz8dd3f29.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.mm1gcx1u647gufh.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.qj06i8rjao4l86x.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.x2yszz8gwchwphb.rcgu.o" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.136e076vj5gzg32a.rcgu.o" "/LIBPATH:C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps" "/LIBPATH:C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\libmagic-d631afe9fd16860e.rlib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\libthiserror-9bc9a8cb7c7db614.rlib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\liberrno-f2a59a8164246d20.rlib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\libwinapi-3fd641a184336611.rlib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\libbitflags-93a6ef986c1a7a15.rlib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\libmagic_sys-dd48239567202748.rlib" "C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\liblibc-c48d00b97b5250c6.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0f357f0f8e8eb48f.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-57325150de1d69ac.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-7a221d01d4c27fb2.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-7bffc6b402bc9229.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-3fd39796b57f4908.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-8572e8a98839f6d6.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libminiz_oxide-6e930372a69395c9.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libadler-ad696ea66c589e9d.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-0a3e7125dc6e7fef.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-7d7ae0874b44dfcc.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-2e82681b8e87518e.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-5ed5a0d27d7423da.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-e970d604d303b37d.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-e73f27a013927059.rlib" "C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-fbb34b1faced902f.rlib" "advapi32.lib" "cfgmgr32.lib" "kernel32.lib" "user32.lib" "magic.lib" "legacy_stdio_definitions.lib"
"kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\anon\\Desktop\\project\\target\\debug\\deps\\project.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\anon\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
= note: LINK : fatal error LNK1181: cannot open input file 'magic.lib'
error: could not compile `project` (bin "project") due to previous error
With an additional panic!()
in the magic-sys
build script it looks like there's a swallowed error that doesn't actually fail the build, but leaves cargo/rustc in a partially configured state:
PS C:\Users\anon\Desktop\project> cargo vcpkg build
Fetching vcpkg
Checkout branch master
Pulling branch master
Installing libmagic
Finished in 1.41s
PS C:\Users\anon\Desktop\project> cargo build
Compiling magic-sys v0.3.0 (C:\Users\anon\Desktop\rust-magic-sys)
Compiling syn v2.0.29
error: failed to run custom build command for `magic-sys v0.3.0 (C:\Users\anon\Desktop\rust-magic-sys)`
Caused by:
process didn't exit successfully: `C:\Users\anon\Desktop\project\target\debug\build\magic-sys-5bcab6812aeb3e3b\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_MAGIC_DIR
cargo:rerun-if-env-changed=MAGIC_DIR
Could not find vcpkg package: Could not find library in Vcpkg tree package libmagic is not installed for vcpkg triplet x64-windows-static-md
cargo:rustc-link-lib=dylib=magic
--- stderr
thread 'main' panicked at 'poor man's debugger', C:\Users\anon\Desktop\rust-magic-sys\build.rs:64:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
This looks like a bug and a problem in magic-sys
. Until I get around to dig deeper into this, a workaround you could try is:
cargo vcpkg build
.\target\vcpkg\vcpkg.exe install libmagic:x64-windows-static-md
cargo build
My Cargo.toml file looks like this -
cargo vcpkg build
executes sucessfully -However when I try to build my package using
cargo build
orcargo run
, it gives me the following linker error -My vcpkg folder (created by cargo-vcpkg) is at
C:\code-projects\rs-scanner\vcpkg
and the environment variableVCPKG_HOME
has been set to the same. How do I fix this error?Things I have tried -
vcpkg integrate install
manually in the created folder