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

Linker error after using cargo-vcpkg for package management #37

Open
nouritsu opened this issue Jun 24, 2023 · 1 comment
Open

Linker error after using cargo-vcpkg for package management #37

nouritsu opened this issue Jun 24, 2023 · 1 comment
Labels

Comments

@nouritsu
Copy link

My Cargo.toml file looks like this -

[package.metadata.vcpkg]
git = "https://github.com/microsoft/vcpkg"
rev = "master"
dependencies = ["libmagic"]

cargo vcpkg build executes sucessfully -

PS C:\code-projects\rs-scanner> cargo vcpkg build
    Fetching vcpkg
    Checkout rev master
  Installing libmagic libmagic
    Finished in 6.84

However when I try to build my package using cargo build or cargo run, it gives me the following linker error -

error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\Aneesh\\AppData\\Local\\Temp\\rustc1GziA8\\symbols.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.12wj6v3cbmco69bl.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.1jq1n2n3hcev1vk5.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.2i405mqxvi87pu41.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.2nstv5n8hntivlu1.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.2srxq9yqfwvm0hq9.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.35h364jj1wwy4bhl.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.3nleu2npeusephn9.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.3xozriqfekg4oetq.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.48wpoluwdzc6265j.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.4i2nqgpim5wa2yjm.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.4w57m2bhklatelce.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.4y82q285kfexjlu3.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.5fuuxk5naeuvtdhj.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.5pc9kk9iu11ma55.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.71hxi9cbswy263i.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.7lye18ybz6rc7d8.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.b2d2vuxo1c1epy9.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.bvj7ely32tlvvk3.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.i2nwwn0ulrpspug.rcgu.o" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.3jak6lzn2sjhax7a.rcgu.o" "/LIBPATH:C:\\code-projects\\rs-scanner\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libmagic-f91a07325f416cd0.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libthiserror-a8e3d939053c7cbd.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\liberrno-3b003e930435be1f.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libbitflags-238d36ea99b67de1.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libmagic_sys-3baaa91aef970a84.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\liblibc-4341ae54cebc8bf7.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libsnafu-80a83afec7c1409c.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libdoc_comment-c5c1ad394bc426e5.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libwalkdir-b478d11cf8fe41bf.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libsame_file-ec9c869d437a9abc.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libwinapi_util-75bfacdb1adbb8c6.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libwinapi-d303619577d28ccc.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\librayon-a3ec2a1cd875fb3e.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\librayon_core-8a1afbd866efc3fe.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libnum_cpus-7e9a3c2c49a19d10.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libcrossbeam_deque-37df0e2c80518ba0.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libcrossbeam_epoch-3ed081d8c7288141.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libmemoffset-2bfda58f6c387739.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libscopeguard-2f60b7f0eb7b7422.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libcrossbeam_channel-dcc8c793356e2f36.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libcrossbeam_utils-20f55305a540803b.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libcfg_if-5ddb140102fcb6a2.rlib" "C:\\code-projects\\rs-scanner\\target\\debug\\deps\\libeither-07d6d1ee9e96223b.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-391022a4250a8b9a.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-3069c74fd845ecc2.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-cae8325b8f11cb55.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-6ecbb4a24be3ec33.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-7cef55517a70b408.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libminiz_oxide-d1e72b1788c7e8f6.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libadler-65d80753bac4b1a6.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-932a6231bea08890.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-04ed514427316340.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-9b75e26b1d0a074f.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-95c2795d82b7b742.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-1bf02ac2d8cdb80a.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-117dfa1fe8688bcf.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-9ac5797c0b4842d0.rlib" "C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-ad271357e078d260.rlib" "magic.lib" "legacy_stdio_definitions.lib" "advapi32.lib" "cfgmgr32.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "user32.lib" "winspool.lib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "ntdll.lib" "msvcrt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\code-projects\\rs-scanner\\target\\debug\\deps\\rs_scanner.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Aneesh\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : fatal error LNK1181: cannot open input file 'magic.lib'

My vcpkg folder (created by cargo-vcpkg) is at C:\code-projects\rs-scanner\vcpkg and the environment variable VCPKG_HOME has been set to the same. How do I fix this error?

Things I have tried -

  • Rebuilding packages
  • Running vcpkg integrate install manually in the created folder
@robo9k
Copy link
Owner

robo9k commented Aug 26, 2023

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

@robo9k robo9k added the bug label Sep 30, 2023
@robo9k robo9k transferred this issue from robo9k/rust-magic Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants