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

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)

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.

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:
Go to MSYS2.org https://www.msys2.org/ (You will also see the installation steps on the site, in case this answer gets outdated).
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.
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.
Run:
pacman -Syu
This will update the packages and databases.
Run (Again - This step may not be needed, but is recommended by MSYS2 in case packages need an additional updates.)
pacman -Syu
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:
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.
Remember to restart your CMD/Windows Terminal/Power Shell for the environment path to take place.

Related

./configure doesn't find Qt5Core, QT5GUI, QT5Widgets

I've recently replaced Win10 by Linux Debian 11.2 on my PC (hence I'm a newbee in Linux). Now, not all programs are available as deb-Files.
I tried to compile source code - here a synthesizer ams-2.2.0 - from a tar.gz files (after unzipping into a separate folder) with steps (as written in the INSTALL.TXT to this source, and obviously usual)
./configure
make
make install
I get a bunch of error messages for missing files, when running ./congigure most resolved by installation of missing packages, but at last it fails with error message:
checking for QTCore Qt5Gui Qt5Widgets >= 5.0... no
configure: error: cannot find Qt5 library >= 5.0
(hope to get all written correctly, because I can't copy from the terminal ... Ctrl-Shift-C doesn't seem to work)
I checked the installation in synaptics and found that Qt-Version is 5.12. So what's wrong here?
I'm afraid to have this error message everytime I try to compile different source codes.
You need to install libqtcore and libqtwidgets with development headers, they are in qtbase5-dev package.
sudo apt install build-essential qtbase5-dev qtchooser

What should I override in cargo for the openssl-rust crate to build? [duplicate]

I tried to install the Iron framework for Rust on Mac OS X 10.11.2, but it failed when I run cargo build or cargo run on compiling openssl's stuff:
failed to run custom build command for `openssl-sys-extras v0.7.4`
Process didn't exit successfully: `/xxx/rust/hello/target/debug/build/openssl-sys-extras-413d6c73b37a590d/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
TARGET = Some("x86_64-apple-darwin")
debug=true opt-level=0
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
HOST = Some("x86_64-apple-darwin")
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-m64" "-fPIC" "-o" "/xxx/rust/hello/target/debug/build/openssl-sys-extras-413d6c73b37a590d/out/src/openssl_shim.o" "-c" "src/openssl_shim.c"
ExitStatus(Code(1))
command did not execute successfully, got: exit code: 1
--- stderr
src/openssl_shim.c:1:10: fatal error: 'openssl/hmac.h' file not found
#include <openssl/hmac.h>
^
1 error generated.
thread '<main>' panicked at 'explicit panic', /xxx/.cargo/registry/src/github.com-0a35038f75765ae4/gcc-0.3.21/src/lib.rs:772
openssl version seems OK:
$ openssl version
OpenSSL 0.9.8zg 14 July 2015
I don't know what I have to do in order to make this installation work and give Iron a try.
As of rust-openssl version 0.8, Homebrew-installed OpenSSL libraries will be automatically detected by the crate, there is no need to set extra environment variables.
If you need to support a version prior to that or choose to not use Homebrew, read on.
This is a known issue (also this and this), but not one that the crate can fix.
The quick solution is to install OpenSSL with Homebrew and then explicitly point to the directories where OpenSSL is found by setting the OPENSSL_INCLUDE_DIR and OPENSSL_LIB_DIR environment variables:
OPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl/1.0.2e/include \
OPENSSL_LIB_DIR=/usr/local/Cellar/openssl/1.0.2e/lib \
cargo build
If you've already done one cargo build, you will need to run cargo clean first to clear our some stale cached information.
If you don't want to set this for every shell you open, add it to your shell initialization files (like ~/.bash_profile). You can make it a bit less brittle by not hard-coding the version number:
export OPENSSL_INCLUDE_DIR=$(brew --prefix openssl)/include
export OPENSSL_LIB_DIR=$(brew --prefix openssl)/lib
If you don't want to use Homebrew, follow the same process but using the appropriate path to your copy of OpenSSL.
The longer reason is well described by andrewtj:
OpenSSL doesn't have a stable ABI so for compatibility purposes Apple have maintained a fork that's compatible with one of the earlier ABIs. They deprecated OpenSSL in 10.7 and finally dropped the headers in 10.11 to push OS X app developers toward bundling their own OpenSSL or using their frameworks. The dylibs have been left around so apps that haven't been updated don't break. You can still link against them but you're opening yourself up to odd compatibility issues by doing so (unless you grab the headers from an earlier OS X release).
With Brew use like this:
brew install openssl
export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include
export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib
cargo clean
cargo build
If you have homebrew's openssl installed just add the following to your Cargo.toml:
[target.x86_64-apple-darwin.openssl-sys]
rustc-link-search = [ "/usr/local/opt/openssl/lib" ]
rustc-link-lib = [ "ssl", "crypto" ]
include = [ "/usr/local/opt/openssl/include" ]
and then cargo clean && cargo build. No breaking OS X by introducing an incompatible openssl into the library load paths, and no forgetting to set/unset environment variables when you want to build (or polluting your shell env when not working on Rust stuff). All in all a much happier and less infuriating approach.
I can't add this answer to my own question where it belongs (because it depends on homebrew), because Shepmaster decided it should be closed but I'll answer here and link to that question.
https://stackoverflow.com/a/39380733/1317564's answer for MacPorts:
sudo port install openssl
export OPENSSL_INCLUDE_DIR=/opt/local/include
export OPENSSL_LIB_DIR=/opt/local/lib
cargo clean
cargo build

Errors with cabal 1.18.1.3 in Windows with latest Haskell Platform (2014.2.0.0)

I can't use cabal with the latest Haskell Platform (2014.2.0.0). I've tried uninstalling, removing all folders from PATH and deleting cabal's library directory, and still no luck
When I run cabal from the command line in the GitBash MINGW32 shell I get the following error:
cabal.exe init
cabal.exe: The program ghc version =6.4 is required but it could not be
found.
(cabal configure, cabal install, etc. all give the same error, except cabal --version)
Now, when I execute cabal from the windows cmd, it runs fine, but when I try to do a cabal init, I get the following:
>cabal init
Package name? [default: toyrsa]
Package version? [default: 0.1.0.0]
Please choose a license:
* 1) (none)
2) GPL-2
3) GPL-3
4) LGPL-2.1
5) LGPL-3
6) AGPL-3
7) BSD3
8) MIT
9) Apache-2.0
10) PublicDomain
11) AllRightsReserved
12) Other (specify)
Your choice? [default: (none)] 3
cabal: git: does not exist
Choosing the default or other options produces the same result. Upgrading to Cabal 1.20 does not help either.
This bug was documented here: https://github.com/haskell/cabal/issues/1613 and that issue claims that it was fixed in the 1.20 series. If you're using 1.20 and still running into it (and sure you're running 1.20 and not an older binary on your path) then you definitely should report it there and reopen the ticket.
Running cabal init from the cmd can be made to work by adding git to the PATH variable. The error at step 3 disappears then. Still seems pretty weird that I need git to create a configuration file for an empty local project with no dependencies.

PLR Installation on Mac Lion

I am trying to install PL/R 8.3.0.13.1 on my MacBook Pro running OS X 10.7.5, Postgres 9.2 and R 2.15.2. I have found on the web a nice step-by-step guide for Windows but I can't find anything similar for Mac.
I got stuck when I run this command [as official documentation] ( http://www.joeconway.com/plr/doc/plr-install.html ):
USE_PGXS=1 make
Output:
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
*** Cannot build PL/R because R_HOME cannot be found.
*** Refer to the documentation for details.
Clearly that means I need to create somehow R_HOME, variable and/or location...
Any idea how to do it?
The error message is actually a bit confusing. If you look at the Makefile of PL/R, the logic is that it uses R_HOME to find R when set, otherwise it tries pkg-config. You have neither set, so it bails out.
I recommend going the pkg-config route if possible. The R_HOME route appears to assume an R installation scheme that might not be universally applicable. Perhaps it applies to builds straight from source.
The above applies to all platforms. Now on OS X, it depends on how you installed R. For example, if you used MacPorts, it would go something like this:
sudo port install pkgconfig
sudo port install R
and then build PL/R itself:
make USE_PGXS=1
But that will break because PL/R does not expect that MacPorts separates the R headers into two separate directories (architecture-dependent and -independent I suppose).
Homebrew might work better, but the principle is the same.
You need to figure out what you should set your PLR environment R_HOME variable. In a terminal session I get this
computername:~ username$ R RHOME #only enter stuff after"$"
/Library/Frameworks/R.framework/Resources
This is at the bottom of that page you linked to:
"Tip: R_HOME must be defined in the environment of the user under which PostgreSQL is started, before the postmaster is started. Otherwise PL/R will refuse to load. See plr_environ(), which allows examination of the environment available to the PostgreSQL postmaster process. "
This is from a webpage describing the problem and offering a fix:
To fix: Add a "R_HOME = '/usr/lib/R' " to /etc/postgresql/version/cluster/environmen
Example Fix for version 8.1:
$ sudo -s
# echo -e "\nR_HOME = '/usr/lib/R'" >> /etc/postgresql/8.1/main/environment
# exit
To Test:
$ sudo /etc/init.d/postgresql-8.1 restart
$ sudo -u postgres psql plr_test
plr_test=# select test();
test
------

Error building openssl-sys crate on Windows

I am trying to compile a Rust program on Windows, but I get this error message:
Compiling openssl-sys v0.6.4
failed to run custom build command for `openssl-sys v0.6.4`
[...]
failed to execute command: The system couldn't find the specified file. (os error 2)
Is `gcc` not installed? (see https://github.com/alexcrichton/gcc-rs#windows-notes for help)
--- stderr
thread '<main>' panicked at 'explicit panic', C:\Users\User\.cargo\registry\src\github.com-0a35038f75765ae4\gcc-0.3.12\src\lib.rs:510
Cargo compiled every other package without problem, but it can't compile the openssl package.
I searched for help with this specific error and found a github issue for hyperium. The first answer references the openssl building guide for Windows.
I don't understand exactly how I have to build openssl in Windows. I installed MinGW and added the bin path to the global PATH variable, so gcc is reachable, but this did not solve the error.
I use Rust 1.2 and Cargo 0.4.0. My project is an example for a Telegram API wrapper.
1) Download ssl
Installs Win32 OpenSSL v1.0.2d
Install it here: C:\OpenSSL-Win32,C:\OpenSSL-Win32\include,C:\OpenSSL-Win32\lib
2) Install MinGW,and add system env path ,,C:\MinGW\bin,important,MinGW's installed path contain char 'MinGW '
3) cmd run env OPENSSLLIBDIR=C:/OpenSSL-Win32/lib OPENSSLINCLUDEDIR=C:/OpenSSL-Win32/include cargo build

Resources