kaMOON
kaMOON

Reputation: 105

Error: Failed to run custom build command for `gmp-mpfr-sys v1.4.0`

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

Upvotes: 2

Views: 3127

Answers (1)

Oleksii Filonenko
Oleksii Filonenko

Reputation: 1653

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.

Upvotes: 3

Related Questions