Can't install cargo-binutils library: Failed to find tool. Is `gcc.exe` installed?
Asked Answered
F

3

5

When I run cargo install cargo-binutils, I get the below error. I have gcc installed and in my path, to the point where where gcc correctly returns the location.

gcc version: gcc.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0

I couldn't find a solution to work, including the explanation in the link listed in the error. I'm on Windows 10.

error: failed to run custom build command for \`backtrace-sys v0.1.37`

Caused by:
  process didn't exit successfully: \`C:\Users\blahblah\AppData\Local\Temp\cargo-installEvEWRS\release\build\backtrace-sys-075604757ab74d2a\build-script-build` (exit code: 1)
--- stdout
cargo:rustc-cfg=rbt
TARGET = Some("x86_64-pc-windows-gnu")
OPT_LEVEL = Some("3")
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("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "gcc.exe" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "src/libbacktrace" "-I" "C:\\Users\\BRENDA~1.BUR\\AppData\\Local\\Temp\\cargo-installEvEWRS\\release\\build\\backtra
ce-sys-1e77a4d4c3ba2eda\\out" "-fvisibility=hidden" "-DBACKTRACE_SUPPORTED=1" "-DBACKTRACE_USES_MALLOC=1" "-DBACKTRACE_SUPPORTS_THREADS=0" "-DBACKTRACE_SUPPORTS_DATA=0" "-DHAVE_DL_ITERATE_PHDR=
1" "-D_GNU_SOURCE=1" "-D_LARGE_FILES=1" "-Dbacktrace_full=__rbt_backtrace_full" "-Dbacktrace_dwarf_add=__rbt_backtrace_dwarf_add" "-Dbacktrace_initialize=__rbt_backtrace_initialize" "-Dbacktrac
e_pcinfo=__rbt_backtrace_pcinfo" "-Dbacktrace_syminfo=__rbt_backtrace_syminfo" "-Dbacktrace_get_view=__rbt_backtrace_get_view" "-Dbacktrace_release_view=__rbt_backtrace_release_view" "-Dbacktra
ce_alloc=__rbt_backtrace_alloc" "-Dbacktrace_free=__rbt_backtrace_free" "-Dbacktrace_vector_finish=__rbt_backtrace_vector_finish" "-Dbacktrace_vector_grow=__rbt_backtrace_vector_grow" "-Dbacktr
ace_vector_release=__rbt_backtrace_vector_release" "-Dbacktrace_close=__rbt_backtrace_close" "-Dbacktrace_open=__rbt_backtrace_open" "-Dbacktrace_print=__rbt_backtrace_print" "-Dbacktrace_simpl
e=__rbt_backtrace_simple" "-Dbacktrace_qsort=__rbt_backtrace_qsort" "-Dbacktrace_create_state=__rbt_backtrace_create_state" "-Dbacktrace_uncompress_zdebug=__rbt_backtrace_uncompress_zdebug" "-D
macho_get_view=__rbt_macho_get_view" "-Dmacho_symbol_type_relevant=__rbt_macho_symbol_type_relevant" "-Dmacho_get_commands=__rbt_macho_get_commands" "-Dmacho_try_dsym=__rbt_macho_try_dsym" "-Dm
acho_try_dwarf=__rbt_macho_try_dwarf" "-Dmacho_get_addr_range=__rbt_macho_get_addr_range" "-Dmacho_get_uuid=__rbt_macho_get_uuid" "-Dmacho_add=__rbt_macho_add" "-Dmacho_add_symtab=__rbt_macho_a
dd_symtab" "-Dmacho_file_to_host_u64=__rbt_macho_file_to_host_u64" "-Dmacho_file_to_host_u32=__rbt_macho_file_to_host_u32" "-Dmacho_file_to_host_u16=__rbt_macho_file_to_host_u16" "-o" "C:\\User
s\\BRENDA~1.BUR\\AppData\\Local\\Temp\\cargo-installEvEWRS\\release\\build\\backtrace-sys-1e77a4d4c3ba2eda\\out\\src/libbacktrace/alloc.o" "-c" "src/libbacktrace/alloc.c"

--- stderr


error occurred: Failed to find tool. Is `gcc.exe` installed? (see https://github.com/alexcrichton/cc-rs#compile-time-requirements for help)
Francinefrancis answered 6/5, 2020 at 21:44 Comment(0)
M
7

This happened to me as well. In my case I got:

failed to run custom build command for zstd-sys v2.0.1+zstd.1.5.2

Caused by: process didn't exit successfully: C:\Users\asili\Documents\Programming\zero2prod\target\debug\build\zstd-sys-f37cc8bfd3eec6ac\build-script-build (exit code: 1)

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

I was able to solve it by following the steps on installing the Visual C++ extension from the VS Code marketplace.

This is how I did it:

  1. Go to MSYS2.org https://www.msys2.org/ (You will also see the installation steps on the site, in case this answer gets outdated).

  2. Download and install msys2-x86_64-20220603.exe (or whichever version is current). The installation is pretty straightforward, just take a note on the installation path as you will need to add this to the environment PATH later on.

  3. A new program called "MSYS2" should've been installed. Open it, and you'll see a terminal window in it. You will run ALL of the commands mentioned below in this terminal. If you close it, open it again.

  4. Run:

pacman -Syu

This will update the packages and databases.

  1. Run (Again - This step may not be needed, but is recommended by MSYS2 in case packages need an additional updates.)
pacman -Syu
  1. Run:
pacman -S --needed base-devel mingw-w64-x86_64-toolchain

You will now see a selection of all the packages. If you don't know which to choose, just press enter on your keyboard and you shall get all of them (that's what I ended up doing).

After that, gcc.exe will be installed the bin folder of mingw64. Therefore:

  1. Add theC:\msys64\mingw64\bin file path to your path environment variable (or Wherever you decided to install it).

In case you need assistance on adding to the path, check out this link.

  1. Remember to restart your CMD/Windows Terminal/Power Shell for the environment path to take place.
Maciemaciel answered 16/6, 2022 at 13:5 Comment(2)
For people using Chocolatey: Just run choco install mingwTransmissible
If you get the error: "signature from "Christoph Reiter (MSYS2 master key) <[email protected]>" is unknown trust", update the pgp keys: see github.com/msys2/MSYS2-packages/issues/…Lapierre
G
3

https://github.com/alexcrichton/cc-rs#compile-time-requirements says:

Windows platforms targeting MinGW (e.g. your target triple ends in -gnu) require cc to be available in PATH. We recommend the MinGW-w64 distribution, which is using the Win-builds installation system. You may also acquire it via MSYS2, as explained [here][msys2-help]. Make sure to install the appropriate architecture corresponding to your installation of rustc. GCC from older MinGW project is compatible only with 32-bit rust compiler.

Try creating a symlink or hardlink to GCC called cc, somewhere on your path.

Gurango answered 6/5, 2020 at 21:52 Comment(2)
Thanks for your help. I tried both of those links and put them on my path (at separate times) and I still get the same error unfortunatelyFrancinefrancis
@Francinefrancis Do where cc and cc --version work properly?Gurango
M
1

As @Cryptovirus mentioned in the comment above, if you use Chocolatey, the solution is way simpler:

Step 1: Run PowerShell as an administrator

Step 2: Install MinGW using Chocolatey by running choco install mingw

Step 3: Reopen the terminal and check the installation by running gcc --version

Milkman answered 21/8 at 13:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.