Go or better known as Golang (Go language) is a general-purpose, open-source, statically typed, fast, and compiled programming language. It has a syntax similar to C language. Programmers use for creating server-side applications, cloud-based applications, AI, data science, games, robotics, and micro-controller programming. Performance-wise, Go is ideal automation, and programmers can simply write programs even for high-performing applications. New updates with the new version being introduced make programming simpler for programmers as well as beginners. It is an easy-to-use language, and that’s the reason beginners are trying to learn it.
Its compiler is an indispensable tool that makes the program you design executable to run. It involves golang that is popularly known as Go programming, which is known for creating efficient and dependable software. When working with Go, you may encounter the error “exec: “gcc”: executable file not found in %path%”. When you encounter this error, don’t need to panic as we are here to help you solve the error efficiently so that you can code your program simpler and peacefully. Let’s figure out how the error warning occurs
How the error shows up
When you are working on a Go project, you end up with the following error
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
Compilation finished with exit code 2
When trying to use Go project, you have the version of golang 1.17 with the golang development tools on windows 10. That’s when you get the error warning. Let’s check out how to remove it
How To Remove the Error “exec: “gcc”: executable file not found in %path%”
The root cause of the error is the missing gcc compiler. We have a way to fix the error that is short as well as really effective. Have a look at it
Option
To fix the error, you need to follow the below steps
- First, you just need to download the program, then follow the on-screen steps to install it successfully.
- When downloading, you need to select the one according to the system you are using like 32-bit or 64-bit. The system of the installer is basically 64-bit, so if you are using a 32-bit system, then you just need to switch it to x86_64, which can be set when you click on the Architecture drop-down.
- You will be asked to choose a location to install it. Now, you just have to wait to let the installation finish successfully.
- Once the installation is finished, go for the system environment variable and add the bin folder recently installed.
- In the last step, open cmd and type gcc -v to check if you have it installed and configured correctly. When you type gcc -v, you get the following
C:\Users\Administrator>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable
-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/
prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-
mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-i
dent -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
- To take the changes set, you need to restart the golang program that you were using when you experience the error warning.
Conclusion
And that’s how you can remove the error “exec: “gcc”: executable file not found in %path%”. You simply need to install the installer to make the error go away.
I hope you find it helpful!