问题
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.
回答1:
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.
回答2:
apt-get install build-essential
This solved the problem. It installs the gcc/g++ compilers and libraries.
回答3:
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.
回答4:
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.
回答5:
On window install http://tdm-gcc.tdragon.net/download, after installed it, you need to reset your PC. that all
回答6:
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
.
回答7:
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.
回答8:
- you need to download MingGW64
- put MingGW64 folder into your $PATH
- run go build xxx.go (with cgo library)
回答9:
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.
回答10:
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.
来源:https://stackoverflow.com/questions/43580131/exec-gcc-executable-file-not-found-in-path-when-trying-go-build