5

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?

13

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.

  • You may also want to do sudo yum group install "Development Tools" – hobs Nov 6 '14 at 15:33
3

The C++ compiler, g++, is either not installed or not available via the PATH environment variable.

Try installing the C++ compiler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.