Error in compiling file using gcc: "/bin/sh: g++: command not found"
Solution 1
It looks like you need to install g++. This is available via dnf
:
dnf install gcc-c++
In the future, if you see any variant of a command not found
error, you can search for the package that provides the "command" with
dnf whatprovides \*/bin/<command>
It used to be that you could just say whatprovides <command>
but Fedora now wants the full path to the binary that you're looking for. Since we don't know it, we use prepend \*/bin
to look in all bin
directories.
Note that dnf
is a replacement for yum
and became the default package manager in Fedora 22. If you're on an early version of Fedora, you can replace dnf
with yum
in any of the previous commands and you'll get the same results.
Solution 2
The C++ compiler, g++, is either not installed or not available via the PATH environment variable.
Try installing the C++ compiler.
Related videos on Youtube
user3658421
Updated on September 18, 2022Comments
-
user3658421 almost 2 years
I want to compile a c++ program in Fedora Linux, but the program isn't compiled correctly. I got the following error:
/bin/sh: g++: command not found make[1]: [*.o] Error 127 make[1]: Leaving directory
Why?
-
Jimmy over 9 yearsYou may also want to do
sudo yum group install "Development Tools"