2

I am using g++ version 4.8.5. I am trying to compile my project using it. It compiles without a problem, when compiling directly from the terminal. But, when using a make file, it gives me following error, even though I am using the same option.

cc1plus: error: unrecognized command line option "-std=c++11"

What am I doing wrong here ?

Edit: as requested, here's my makefile line:

main: main.cc
    @g++ -std=c++11 main.cpp -o run
9
  • Can you post the Makefile somewhere? Commented Nov 25, 2016 at 4:48
  • @solti Ah, I didn't know about that. Why do I need to have two dashes ? Commented Nov 25, 2016 at 4:51
  • 2
    You don't, -std=c++11 is a correct compiler switch for C++11 Commented Nov 25, 2016 at 4:51
  • 1
    Hmm, have you tried specifying g++'s absolute path? Something like this: @/usr/bin/g++-4.8 -std=c++11 main.cpp -o run Commented Nov 25, 2016 at 4:56
  • 2
    @MartinJungblutSchreiner Thanks buddy. It worked. Problem was the path. When using absolute path, it compiled correctly. Thanks again. Can you put it as an answer ? I can accept that then. Commented Nov 25, 2016 at 5:00

1 Answer 1

3

Try using g++'s absolute path:

main: main.cc
    @/usr/bin/g++-4.8 -std=c++11 main.cpp -o run
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.