gcc is recognized by cmd, but not by bash - windows

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

Related

Installing gfortran via macports on Mac OS high sierra

My supervisor has asked that I install a fortran compiler on my mac and suggested using MacPorts to install gcc6. I have tried to install gcc6 a number of times but each time it doesn't seem to come with gfortran. No matter what I do I cannot seem to figure out what is going on and how to get around it.
Any hep on the matter would be greatly appreciated.
Here is the command used to install gcc:
sudo port install gcc6
MacPorts allows you to have multiple versions of gcc installed. Before you get gfortran executable you have to select the default version.
First - install gcc:
sudo port install gcc9
After this command you will have gfortran under gfortran-mp-9 alias. To make gfortran-mp-9 the default and make it reachable via gfortran command do:
sudo port select --set gcc mp-gcc9
The examples above assumed gcc9, but you might need adjust the above gcc version to the one you need to work with.
With macports the correct command to install fortran would be
sudo port install gcc6 +gfortran
This will install gfortran. You may want to refer to the gfortran manual along with other Fortran references you may be using.
Note: You may choose some other version of gcc, of course. You can search for which versions are available on the macports site.

valac command not found on windows

I have tried to get vala working on Windows and it does not work, I have followed the steps on the website:
I downloaded and installed msys2
Then I ran
pacman -Syu
pacman -Su
Then I ran the command on the vala website
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-vala
Then I tried to run valac and it says command not found.
Am I missing something? I tried just vala but that does not work, I tried to run the command again and it said that it was already installed and up to date.
You probably did not start "mingw64.exe" (The msys2 subsystem for mingw64-x86_64).
There are three distinct subsystems in msys2 (each also has its own pacman package repository):
msys2
mingw32
mingw64
You can launch a shell for any of them. The current best solution is to use the included launchers (msys2.exe, mingw32.exe and mingw64.exe).
See here for more documentation:
https://www.msys2.org/wiki/Launchers/
https://www.msys2.org/wiki/MSYS2-introduction/

exec: "gcc": executable file not found in %PATH% when trying 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 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.

cygwin bash not returning a valid result

I am following this :
Step 2: Installing Cygwin
Cygwin can be downloaded from http://www.cygwin.com
Run the setup file.
Install from internet. Specify C:\cygwin as the root directory.
In the Select Packages dialog box, select the packages required. gcc-core, gcc-g++, gdb, and make packages are most important. These are the C core, C++ core, the GNU Debugger and the GNU version of ‘make’ utility. These packages will be under the ‘Devel’ category.
Complete the installation.
Step 3: Testing Cygwin
To test whether Cygwin was installed properly, try the following by opening the bash shell:
cygcheck -c cygwin
gcc --version
g++ --version
make --version
gdb --version
If the version details are displayed for all these commands, the installation of Cygwin has been successful.
I got this from here
But the result I get is:
What is wrong or missing with my installation.
Follow up question:
I wanted to use the terminal window in netbeans that is why I installed this.
In this terminal widnow I also have problem. I cant type anything on it. Is this the reason for it?
Try to run /usr/bin/g++. If it is not found, then you don't have g++ installed (installation may have had problems).
You can follow the same procedure for the rest of your commands
If /usr/bin/g++ runs successfully, it means you don't have /usr/bin in your PATH (which is very unlikely). You can put that in your PATH in your startup file.

erlang.mk buildtool is unable to detect windows

I have build a website with Erlang and Cowboy with ErlyDTL on a Linux OS.
Now I want that my website can run on Windows and want to use the Erlang.mk with Relx build tool.
When I give the make command it gives me the error:
Unable to detect platform. Please open a ticket with the output of
uname -a.
uname -a output:
MINGW32_NT-6.2 LENOVO-... 2012-11-21 22:34 i686 Msys
How can I fix this problem in a easy way with explanation because I don't know much of makefiles ;).
Specs:
I have Windows 8.1 64 bit OS.
My Erlang.mk is version 1.2.0-634-g2f69190.
I installed MinGW with msys so I can run make and make distclean.
I have the following extra packages installed during this intallation:
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
msys-base
So the PATH to MinGW is c:\MinGW.
With CMD I started C:\MinGW\msys\1.0\msys.bat
Then with the bash shell I ran de postinstall script pi.sh. This gave me no errors.
Then I have installed some extra packages for MinGW with success:
mingw-get install msys-rxvt
mingw-get install msys-unzip
mingw-get install msys-zip
mingw-get install msys-wget
I have red https://github.com/ninenines/erlang.mk/issues/294 but I couldn't understand what I have to do because the lack of explanation.
So is there a solution? If yes what is it and please give some explanation with it so I can fix my problem and understand what I'm doing.
Thanks in advance

Resources