helgoboss / reaper-rs

Rust bindings for the REAPER C++ API
MIT License
80 stars 8 forks source link

`cargo build` fails on Windows if Mingw and gnu-toolchain isn't installed #53

Closed Schroedingers-Cat closed 2 years ago

Schroedingers-Cat commented 2 years ago

Running cargo build fails for the dependency wepoll-ffi on Windows 10 if mingw and the gnu-toolchain aren't installed:

error: failed to run custom build command for `wepoll-ffi v0.1.2`

Caused by:
  process didn't exit successfully: `P:\ath\To\reaper-rs\target\debug\build\wepoll-ffi-fd0975e38ca95e02\build-script-build` (exit code: 1)
  --- stdout
  TARGET = Some("x86_64-pc-windows-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-pc-windows-gnu")
  CC_x86_64-pc-windows-gnu = None
  CC_x86_64_pc_windows_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-pc-windows-gnu = None
  CFLAGS_x86_64_pc_windows_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-DNULL_OVERLAPPED_WAKEUPS_PATCH" "-o" "P:\\ath\\To\\reaper-rs\\target\\debug\\build\\wepoll-ffi-30c14fc956d93b40\\out\\vendor/wepoll/wepoll.o" "-c" "vendor/wepoll/wepoll.c"

  --- stderr

  error occurred: Failed to find tool. Is `gcc.exe` installed? (see https://github.com/alexcrichton/cc-rs#compile-time-requirements for help)

warning: build failed, waiting for other jobs to finish...
error: build failed

Additional info:

rustup show
Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\Username\.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.58.1 (db9d1b20b 2022-01-20)

Installing mingw via chocolatey and the gnu toolchain via rustup fixes the issue:

choco install mingw -y
rustup toolchain install stable-x86_64-pc-windows-gnu

The docs don't mention this, so I'm wondering if there's a recent change anywhere in the dependencies or if it's just missing.

helgoboss commented 2 years ago

Thanks for reporting. Sounds like a minor update in a dependency that's not so minor after all.

helgoboss commented 2 years ago

@Schroedingers-Cat Do you still have this issue? I just removed my local Cargo.lock, even renamed all gcc.exe files on my machine ... and it worked. But hey, aren't you building with the wrong toolchain? Looks like your target is x86_64-pc-windows-gnu (see your log). It must be x86_64-pc-windows-msvc.

Please reopen if you still have this issue.

Schroedingers-Cat commented 2 years ago

Will try out if it works with GCC removed. But that sounds promising!

But hey, aren't you building with the wrong toolchain? Looks like your target is x86_64-pc-windows-gnu (see your log). It must be x86_64-pc-windows-msvc.

My default target is msvc (see my other terminal output). I tried forcing cargo into using msvc when building but even then cargo built the dependency wepoll-ffi with the gnu toolchain and failed if it wasn't available.