5

I installed gcc 5.4.0 recently, on Windows using Cygwin, because I wanted to test the C++14 standard features of g++. When I tried to compile, I get the following error:

$ g++-5.4.0 -std=c++14 test.cpp
-bash: g++-5.4.0: command not found

This is the code I wrote inside test.cpp:

#include <iostream>

int main()
{
    auto lambda = [](auto x){ return x; };
    std::cout << lambda("Hello generic lambda!\n");
    return 0;
}

What could be the problem? I also tried replacing C++14 with C++11 in the command, but got the same error.

1
  • 7
    The error is that there is no g++-5.4.0 in your path, not that your copy of GCC doesn't support C++14.
    – ildjarn
    Commented Jun 25, 2016 at 6:50

1 Answer 1

7

When Cygwin installs a g++ version (in your case, 5.4.0), it will place the g++ executable in your PATH variable. But the installation name is just g++.exe, so you can call the program like this:

g++ -std=c++14 test.cpp

If you really wanted to call the compiler with g++-5.4.0, you could symlink the actual g++ executable to that name:

ln -s /usr/bin/g++.exe /usr/bin/g++-5.4.0.exe

then you will be able to call the program from the command line with either g++ or g++-5.4.0:

g++-5.4.0 -std=c++14 test.cpp
g++ -std=c++14 test.cpp
1
  • 1
    Thank you for the precise answer! I recently started using g++, hence the naive question.
    – Ebin J
    Commented Jun 25, 2016 at 7:16

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