Exec: "gcc": executable not found in% PATH% when trying to go build

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 chain code is imported:

 import ( "fmt" "strconv" "github.com/hyperledger/fabric/core/chaincode/shim" pb "github.com/hyperledger/fabric/protos/peer" ) 

Everything works fine in Docker .

+45
windows build go cgo hyperledger-fabric
source share
11 answers

gcc (the GNU compiler compilation) provides the C compiler. On Windows, install TDM-GCC . The github.com/miekg/pkcs11 package uses cgo . Cgo allows you to create Go packages that invoke C code.

+44
source share
 apt-get install build-essential 

This solved the problem. It installs gcc / g ++ compilers and libraries.

+8
source share

1) Install .exe from> https://sourceforge.net/projects/mingw-w64/

1.2)! use x86_64

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 System Variables . It works for me.

! To edit the Path variable, press the Windows key, enter "path", select "Edit system environment variables", click "Environment variables", find the Path variable in System variables and User variables , then edit.

+6
source share

The correct explanations for why the go build does not work for hyperlinks in a Windows environment are given as other answers. For your compilation purposes, to make it work without installing anything extra, you can try the following

 go build --tags nopkcs11 

It worked for me. Hope the same for you too.

+3
source share

In the installation window http://tdm-gcc.tdragon.net/download , after installation you need to restart the computer. all this

+3
source share

The error correction instruction "exec:" gcc ": the executable was not found in% PATH%" with MSYS2:

  • Download MSYS2.
  • Place the MSYS2 folder in your $ PATH folder.
  • Run the MSYS2 command-line tool.
  • Run this command: pacman -S gcc .
+1
source share

gcc is not required if you are not cross-compiling for a windowless platform or using cgo. However, if you still need gcc, you must install MinGW, which provides a gcc port for Windows (Cygwin and msys should also work, although I have never tested this).

Edit: I now see from your error message that this is a dependency that requires gcc. If you did not already know this, gcc is a c / C ++ compiler, in which case you probably need to compile the c source files included in the dependency or sub-dependency.

0
source share
  • you need to download MingGW64
  • put the MingGW64 folder in your $ PATH
  • run go build xxx.go (with cgo library)
0
source share

Hello jaswanth, the main problem is that you have not registered your% GO_HOME% \ pkg \ tool \ windows_amd64 for your Environment Path yet. % GO_HOME% is the repository where you install Go for the first time.

0
source share

I ran into the same problem when trying to debug a go project using Intellij GoLand in Ubuntu 18.04 . Installing the gcc collection of GNU compilers with the following command will fix this

 sudo apt install gcc 

Please find more information about GCC here.

0
source share

I just downloaded tdm64-gcc5.1.0.2.exe and it worked for me. Thanks @peterSO.

0
source share

All Articles