c++: error: unrecognized command line option ‘-std=c++14’
Asked Answered
T

2

12

I just moved my PC from Ubuntu 15.10 to Linux Mint 17.3.

Before this shift, this project compiled just fine in CLion. Now, it gives the following error:

c++: error: unrecognized command line option ‘-std=c++14’

This is probably due to this line in my CMake file:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -W -Wall -Wextra -pedantic")

I suspect this error is due to some outdated library/compiler. I don't know exactly what I need to do.

P.S.: I know that C++14 is not completely supported in CLion, and the editor will complain about syntax errors, but it will compile fine nonetheless.

Twyla answered 27/3, 2016 at 8:37 Comment(3)
What gcc version do you have?Alrick
@Alrick g++ --version returns g++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4Twyla
gcc 4.8 doesn't have much of c++14: "Currently the only difference from -std=c++11 is support for return type deduction in normal functions, as proposed in N3386. "Alrick
A
22

-std=c++14 is called -std=c++1y in old gcc versions (at least 4.9 and older).

Alrick answered 27/3, 2016 at 8:59 Comment(5)
-std=c++1y doesn't support all of C++14.Twyla
-std=c++1y is the same as -std=c++14 (in 5.x they are synonyms). The standard support depends on the compiler version, not on the option name.Alrick
Is there a way to use clion with the latest g++?Twyla
It's not about clion, you need to install the newer gcc first.Alrick
I don't want to replace the gcc packages of my distro with the newer versions, for stability. I compiled gcc from source and have the binaries in a directory. Can I point CLion to use it?Twyla
C
3

I am working on a high-performance cluster and the "default" version of gcc is 4.8.5, which is why I also ran into the error c++: error: unrecognized command line option ‘-std=c++14’.

Not having sudo rights, I could solve the issue by loading a module (https://modules.readthedocs.io/en/latest/) containing a more recent gcc version (module load compiler/gnu/9.1). So if you are working on a cluster check out module avail (or in general the documentation of the cluster).

Christelchristen answered 7/6, 2022 at 15:10 Comment(1)
Thank you so much! I hit this same snag while trying to install pycistopic, and since I didn't have sudo rights, worried I would need to install a local gcc. I checked the gcc version used by default (gcc --version) and it was "4.8.5 20150623 (Red Hat 4.8.5-28)", and used module avail and found gcc/6.4.0 on our cluster. no longer getting ERROR: Could not build wheels for annoy. And after installing cargo rust, I could build wheels for pybigtools too.Rosannrosanna

© 2022 - 2024 — McMap. All rights reserved.