I am trying to install Rust via the command line on a Windows VM (https://github.com/sansyrox/robyn/pull/263). The script on the main Rust installation website only supports *nix os.
What are the commands to download and install Rust on a Windows VM?
Follow directions in Other ways to install rustup. Download rustup-init.exe based on the target toolchain of your choice:
64-bit MSVC: x86_64-pc-windows-msvc/rustup-init.exe
64-bit GNU: x86_64-pc-windows-gnu/rustup-init.exe
32-bit MSVC: i686-pc-windows-msvc/rustup-init.exe
32-bit GNU: i686-pc-windows-gnu/rustup-init.exe
You can use --help to see what options there are to configure the installation:
> .\rustup-init.exe --help
rustup-init 1.24.3 (ce5817a94 2021-05-31)
The installer for rustup
USAGE:
rustup-init.exe [FLAGS] [OPTIONS]
FLAGS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-y Disable confirmation prompt.
--no-update-default-toolchain Don't update any existing default toolchain after install
--no-modify-path Don't configure the PATH environment variable
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--default-host <default-host> Choose a default host triple
--default-toolchain <default-toolchain> Choose a default toolchain to install
--profile <profile> [default: default] [possible values: minimal, default, complete]
-c, --component <components>... Component name to also install
-t, --target <targets>... Target name to also install
The basic -y should work for you; it will install rustup and the default toolchain. You can of course use wget to download the installer within a script.
> wget https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe
> .\rustup-init.exe -vy
Note, the MSVC toolchain will require you to install the Visual C++ Build Tools to function. I'm unsure how to install those in a CLI only environment. Hopefully the .exe for that functions similarly.
See also:
What are the differences between the GNU and MSVC Rust toolchain?
How to install Visual C++ Build tools?
Install it with scoop for easier package management on your system with a single command:
scoop install rustup-gnu for GNU toolchain
or
scoop install rustup for MSVC toolchain
Then you can update rustup or uninstall it whenever you want with:
scoop upgrade rustup
scoop uninstall rustup.
Please help me to install dev toolset-8 in rhel 8 image.
i have pulled the base image as below . I want to install devtoolset-8. is there any other way please let me know.
sudo docker pull registry.access.redhat.com/ubi8/ubi:8.2
According to that article, you can check if you have access to Red Hat Software Collections (RHSCL) by running the following command by the root user:
$ su -
# subscription-manager repos --list | egrep rhscl
If you have, enable necessary software repo and then install devtoolset:
# subscription-manager repos --enable rhel-7-server-optional-rpms
# yum install devtoolset-8
The other answer seems to be for RHEL 7.
On the RedHat site
Chrisian Labisch answered this with:
RHEL 8 doesn't work with Software Collections, RHEL 8 uses modules instead.
sudo dnf module list
In RHEL 8 you find the developer tools in the CodeReady Builder repository. :)
sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms
But even that seems to be unneeded because the system compiler version for RHEL is already GCC 8, so you would normally only need devtoolset-9 or up for it, if I understood the purpose correctly.
Additionally this blog post outlines the differences between the old SCL toolsets and the new AppStreams concept.
devtoolset is called gcc-toolset in RHEL8.
The following commands worked for me:
microdnf install -y gcc-toolset-12
scl enable gcc-toolset-12 bash
gcc --version
# gcc (GCC) 12.1.1 20220628 (Red Hat 12.1.1-3)
I'm using windows sub-system for linux, installed ubuntu, and bash is running smoothly.
I'm trying to use make, and it seems that bash doesn't recognize gcc. Tried adding it to PATH, but nothing changed. The weird thing is - cmd does recognize gcc.
Do I need to install it again?
Have you tried to install gcc to the Ubuntu Sybsystem for Windows?
sudo apt install gcc
I am using Windows 10. When I tried to build Chaincode it reported this error
# github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
exec: "gcc": executable file not found in %PATH%
My chaincode imports:
import (
"fmt"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
It's running fine in Docker.
gcc (the GNU Compiler Collection) provides a C compiler. On Windows, install TDM-GCC. The github.com/miekg/pkcs11 package uses cgo. Cgo enables the creation of Go packages that call C code.
If you are running Ubuntu do:
apt-get install build-essential
This solved the problem. It installs the gcc/g++ compilers and libraries.
I also encountered this message, but in my case, it was missing gcc.exe. I used choco and installed mingw, and then it worked.
details:
download choco
choco install mingw -y
check: gcc -v
1) Install .exe from > https://sourceforge.net/projects/mingw-w64/
1.2) ! use x86_64 architecture
2) Add C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin to PATH in User Variables and in System Variables. For me it works.
! To edit Path variable press Windows key, type 'path', choose 'Edit the system environment variables', click 'Environment Variables', find Path variable in System variables and in User variables then edit.
On Windows install http://tdm-gcc.tdragon.net/download, that is all.
If you are using an alpine based image with your Dockerfile
Install build-base which will be met with your requirements.
apk add build-base
$ go env
check CGO_ENABLED if its 1 change it to 0 by
$export CGO_ENABLED=0
For my case :
os: windows 10
command:
choco install mingw
install choco if not installed:
Link: https://www.liquidweb.com/kb/how-to-install-chocolatey-on-windows/
worked for me.
The proper explanations why go build does not work for hyperledger in Windows environment are given as other answers.
For your compilation purposes, just to make it work without installing anything extra, you can try the following
go build --tags nopkcs11
It worked for me. I hope same works for you too.
You can try - this is not a solution but a temp workaround
cgo_enabled=0 go build
Once you install gcc - and make sure %PATH has a way to find it (gcc.exe) - this should go away.
Also running this one will ensure the cgo_enabled variable will stay this way as long as terminal is open. That way you don't have to prefix it each time you do a build.
export cgo_enabled=0 go build
just followed instructions from following and it solve my issue
https://code.visualstudio.com/docs/cpp/config-mingw
it ask to install Mingw-w64 via MSYS2
important command is pacman -S --needed base-devel mingw-w64-x86_64-toolchain
then add C:\msys64\mingw64\bin to PATH
thanks
For Ubuntu, what worked for me was to simply run:
sudo apt install gcc
On Amazon Linux 2:
Install go
wget https://go.dev/dl/go1.18.1.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
Install gcc
sudo yum groupinstall "Development Tools"
I recommend using the package group, even though it can be done without it, because groupinstall gives you the necessary packages to compile software on Amazon Linux and Redhat, CentOS for that matter.
on Ubuntu its very easy but on windows need to do it:
download MinGW on http://www.mingw.org/
install on basic package Gcc-g++ (see this image)
add on environment Patch of windows variables.
restart and continue with "go get ..."
If you are running Ubuntu do:
sudo apt-get update
sudo apt-get install build-essential.
If the above commands do not work do:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
The main component contains applications that are free software, can be freely redistributed and are fully supported by the Ubuntu team. & The universe component is a snapshot of the free, open-source, and Linux world.
Then install package by following command in terminal:
sudo apt-get update
sudo apt-get install build-essential.
For more info click here: https://itectec.com/ubuntu/ubuntu-problem-installing-build-essential-on-14-04-1-lts-duplicate/
Just add this to your Dockerfile
RUN apk add alpine-sdk
gcc should not be necessary, unless you are cross compiling for a non-windows platform, or use cgo.
If you still need gcc, however, you should install MinGW, which provides a gcc port for Windows (Cygwin and msys should also work, although I have never actually tested this).
Edit: I see from your error message now, that it is a dependency that requires gcc. If you didn't already know this, gcc is a c/c++ compiler, and in this case it is probably needed to compile c source files included by a dependency or sub-dependency.
Instruction to fix the "exec: “gcc”: executable file not found in %PATH%" error with MSYS2:
Download MSYS2.
Put MSYS2 folder into your $PATH.
Start the MSYS2 command line program.
Run this command: pacman -S gcc.
Kindly install the MINGW after GUI will automatically take.
http://mingw.org/wiki/Getting_Started
On Windows, you can install gcc by Scoop:
scoop install gcc
you need to download MingGW64
put MingGW64 folder into your $PATH
run go build xxx.go (with cgo library)
Hi jaswanth the main problem is that you haven't register your %GO_HOME%\pkg\tool\windows_amd64 to yuour Environment Path.
%GO_HOME% is the repository where you install your go at the first time.
same as other, just install tdm-gcc, but you can use its terminal, "MinGW", you can access it from start menu folder tdm-gcc, after start, browse to your project, and run it again
I'm a Windows user and I downloaded tdm-gcc (MinGW-w64 based) from the link below:
https://jmeubank.github.io/tdm-gcc/
After installation, it made a folder named "TDM-GCC-64".
I added "C:\TDM-GCC-64\bin" to my PATH, And it fixed my problem.
I am installing an egg packaged for pip, inside my virtualenv, under Python 2.7.2.
The egg has 16 requirements, one of which (pycryptopp 0.5.29) is known to fail with gcc-4.6 and hence must be compiled with 4.5. The system has both gcc-4.6 (default) and gcc-4.5 installed.
How do I configure/hack pip install to build this package specially? (or do I just temporarily kludge the link /usr/bin/gcc while installing this package)
Do I need to clean up the existing (virtualenv)/build directory where it broke, and if so how?
(I already read the pip documentation and searched SO + SU)
No need to fiddle around with symlinks here. On most Linux systems you can set the compiler to use with the CC env var. In case of pycryptopp and pip the following might help:
$ CC=/usr/bin/gcc-4.5 pip install pycryptopp
given that you have GCC 4.5 installed in that location. This worked fine for me on Ubuntu 11.10 (oneiric) with packages gcc-4.5 and g++-4.5 installed.
(I retitled the question from "How to use pip install where one requirement must be compiled with gcc-4.5?")
1) The correct method is to build with "--disable-embedded-cryptopp" which links to libcryptopp. Some people report runtime issue but It Works For Me.
pip install --install-option="--disable-embedded-cryptopp" pycryptopp
2.) A truly ugly workaround which I used (and which ulif helpfully points out can be obviated by using CC=.. ) is to invoke pip install specifically for the problem package, and temporarily kludge the link to gcc.
pushd /usr/bin; sudo rm gcc-4.6; ln -s gcc-4.5 gcc; popd;
pip install pycryptopp
pushd /usr/bin; sudo rm gcc-4.5; ln -s gcc-4.6 gcc; popd;
Further reasons this is bad: it requires root access and messing with the link to gcc binary. It certainly can't be Makefile'd.
Adding this for completeness to extend upon the existing good answers; if you are on apt based distribution such as Ubuntu or Debian, you can do the following:
Step 1: Install the versions of gcc/g++ you need
sudo apt install gcc-7 gcc-8 g++-7 g++-8
Step2: Install your gcc/g++ versions into "alternatives" system of your OS:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80
Step 3: Select your active gcc/g++ versions
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
It will in each case ask you which version you want, or use the "weight" you provided to select automatically for you:
Selection path Priority Status
--------------------------------------------------------------------
* 0 /usr/bin/gcc-8 80 auto mode
1 /usr/bin/gcc-8 80 manual mode
2 /usr/bin/gcc-7 70 manual mode
Press ENTER to maintain, or type the selection number to the corresponding version.
TIP: If you want to delete a version, simply use this:
sudo update-alternatives --remove gcc /usr/bin/gcc-7
You will still use root/sudo access to do this, but it is much cleaner than dealing with manually deleting/creating links, or specifying environment variables on the commandline. It is the recommended way of selecting versions for all kinds of things in arpt based distributions.