0
votes

I'm trying to use rug, so I copied rug = "1.11.0" to my Cargo.toml file under [dependencies]. But I got an error: failed to run custom build command for gmp-mpfr-sys v1.4.0. I do not get any errors with other dependencies, why does this error occur and how can I fix it?

I'm using Windows 10.

The entire error message:

error: failed to run custom build command for gmp-mpfr-sys v1.4.0

Caused by: process didn't exit successfully: C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-9f6df87a2d8ae0bb\build-script-build (exit code: 101) --- stdout cargo:rerun-if-env-changed=GMP_MPFR_SYS_CACHE $ mkdir -p "C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\try_external_doc" $ cd "C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\try_external_doc" $ printf '%s' "// try_ext"... > "C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\try_external_doc\try_external_doc.rs" $ "rustc" "try_external_doc.rs" "--emit=dep-info,metadata" >& /dev/null $ printf '%s' "#![feature"... > "C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\try_external_doc\try_external_doc.rs" $ "rustc" "try_external_doc.rs" "--emit=dep-info,metadata" >& /dev/null $ rm -r "C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\try_external_doc" $ mkdir -p "C:\Users\kimchi\OneDrive\Desktop\Rust\lab1b\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\lib" $ mkdir -p "C:\Users\kimchi\OneDrive\Desktop\Rust\target\debug\build\gmp-mpfr-sys-dcad4e240d8aac65\out\include"

--- stderr thread 'main' panicked at 'Windows MSVC target is not supported (linking would fail)', C:\Users\kimchi.cargo\registry\src\github.com-1ecc6299db9ec823\gmp-mpfr-sys-1.4.0\build.rs:951:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

1
Welcome to Stack Overflow. In order for us to give full and relevant answers, please edit the question to include the complete error message. Here we can only guess at the root cause.Jmb
Crates whose name ends with -sys are usually Rust interfaces to libraries written in C or include a component written in C. The error you report is related to the C component, but I can't tell any more without the full error.Jmb

1 Answers

1
votes

gmp-mpfr-sys is not available on Windows when you use the default MSVC compiler backend (see Windows MSVC target is not supported (linking would fail) in the panic message).

You need to install MSYS2 first.

Then, in MSYS2 install necessary packages:

pacman -S pacman-mirrors
pacman -S diffutils make mingw-w64-x86_64-gcc

Build your crate inside of MSYS2 environment with cargo.