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

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.

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

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).

Related

gcc compiler giving error because missing files for flags

I am trying to compile code for a course. I want to use the -Wall -pedantic and -std=c99 tag since those are used to check the code by the teachers. In a previous course where I had to do this I ran the code on a linux virtual boot provided by the teachers where everything was preinstalled to run the code. But since then I switched over my PC to linux from windows so I do not have those things installed. when running the following command in my terminal
gcc −std=c99 −Wall −pedantic myprogram.c
I get the following errors roughly translated to english.
gcc: error: -std=cgg: File or directory does not exist
gcc: error: -Wall: File or directory does not exist
gcc: error: -pedantic: File or directory does not exist
what do I have to install and how to make this working?

Spin: gcc-6: unrecognized command line option

I want to use SPIN model checker on Windows 10 (64bit) and I have followed the instructions on the spin website:
I installed MinGW and gcc, updated path, and checked in the command prompt it shows version 6.3.0
I installed ActiveTCL updated path, updated path with iSpin too, I can get iSpin to open
when I try to compile pre-included example file leader.pml I get this error:
spin: preprocessing failed gcc -std=gnu99 -Wformat-overflow=0 -E -x c "leader.pml" > "pan.pre"
gcc: error: unrecognized command line option '-Wformat-overflow=0'; did you mean '-Wstrict-overflow='?
I don't understand the error, does someone know what is missing?
The error says exactly what the problem is: -Wformat-overflow=0 is not a recognized command line option.
Not that you are using MinGW GCC 6.3.0, which is very old.
Consider using MinGW-w64 which is much more recent. Currently GCC 11.2.0 is the latest version. You can find a standalone build at https://winlibs.com/
So please try with a newer GCC. If it still does't work run gcc --help -v to see all command line options.

fatal error: 'omp.h' file not found

I'm trying to compile my OpenMP program, but it doesn't work, this error message shows:
fatal error: 'omp.h' file not found
I've tried the solutions for this problem here, but nothing worked with me.
please help
I'm Mac user
You probably need to reinstall with:
brew reinstall gcc --without-multilib
Then you need to make sure you use the homebrew version of gcc (rather than anything Apple supplies) by running gcc-5 rather than plain gcc. You can check its name and version by running the following because homebrew normally always installs everything to /usr/local/bin:
ls /usr/local/bin/gcc*
Finally, you need to add the -fopenmp flag to your compiler invocation to tell the compiler to do the OpenMP thing.
So, your command will look like:
gcc-5 -fopenmp program.c -o program

Caffe compilation fails due to unsupported gcc compiler version

I struggle with Caffe compilation. Unfortunately I failed to compile it.
Steps I followed:
git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build
cd build
cmake ..
make all
Running make all fails with the following error message:
[ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o
In file included from /usr/include/cuda_runtime.h:59:0,
from <command-line>:0:
/usr/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.9 and up are not supported!
#error -- unsupported GNU version! gcc 4.9 and up are not supported!
^
CMake Error at cuda_compile_generated_im2col.cu.o.cmake:207 (message):
Error generating /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_im2col.cu.o
Software version:
OS: Debian.
gcc version: 5.3.1.
nvcc version: 6.5.12.
cat /proc/driver/nvidia/version result:
NVRM version: NVIDIA UNIX x86_64 Kernel Module 352.63 Sat Nov 7 21:25:42 PST 2015
GCC version: gcc version 4.8.5 (Debian 4.8.5-3)
Attempts to solve the problem
1st try
Simple solutions are often best ones, so (as suggested here) I tried to comment out macro checking gcc version from /usr/include/host_config.h (line 82). Unfortunately it doesn't work and compilation fails badly:
1 catastrophic error detected in the compilation of "/tmp/tmpxft_000069c2_00000000-4_im2col.cpp4.ii".
2nd try
I tried to run:
cmake -D CMAKE_CXX_COMPILER=g++-4.8 ..
make
but it fails with exactly the same error message (even though g++-4.8 should be accepted).
3rd try
I've found similar problem (though not related to Caffe) and I tried to solve it as suggested in the accepted answer.
What I did:
I've ran grep -iR "find_package(CUDA" caffe command and found Cuda.cmake file which has find_package(CUDA 5.5 QUIET) in line 225.
I added set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8) to Cuda.cmake, line before line: find_package(CUDA 5.5 QUIET).
I removed everything from build directory and ran cmake and make again - with and without -D CMAKE_CXX_COMPILER=g++-4.8.
Unfortunately result is exactly the same. Caffe probably overwrites it somehow - I didn't figure it out how.
make VERBOSE=1 2>&1 | grep -i compiler-bindir returns nothing.
What's interesting, make VERBOSE=1 prints command that fails, which is:
/usr/bin/nvcc -M -D__CUDACC__ /mydir/caffe/src/caffe/util/im2col.cu -o /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -DUSE_LMDB -DUSE_LEVELDB -DUSE_OPENCV -DWITH_PYTHON_LAYER -DGTEST_USE_OWN_TR1_TUPLE -Xcompiler ,\"-fPIC\",\"-Wall\",\"-Wno-sign-compare\",\"-Wno-uninitialized\",\"-O3\",\"-DNDEBUG\" -gencode arch=compute_20,code=sm_21 -Xcudafe --diag_suppress=cc_clobber_ignored -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=useless_using_declaration -Xcudafe --diag_suppress=set_but_not_used -Xcompiler -fPIC -DNVCC -I/usr/include -I/mydir/caffe/src -I/usr/include -I/mydir/caffe/build/include -I/usr/include/hdf5/serial -I/usr/include/opencv -I/usr/include/atlas -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/mydir/caffe/include -I/mydir/caffe/build
when I add --compiler-bindir /usr/bin/gcc-4.8 flag manually, it prints error:
nvcc fatal : redefinition of argument 'compiler-bindir'
which may be related to this bug report.
Edit: I didn't notice that --compiler-bindir and -ccbin are the same options, and the latter is already set in above command that failed. When I changed -ccbin /usr/bin/cc to -ccbin /usr/bin/gcc-4.8 in above command that failed, it completes successfully. Now I need to find option in Caffe's CMake file that overwrite -ccbin in all subsequent Caffe's CMakes. Looking at cmake/Cuda.cmake:252:list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA} seems to be good way to go.
How can I successfully complete my compilation? Any help is appreciated.
Related SO questions:
host_config.h:unsupported GNU version! gcc versions later than 4.9 are not supported.
CUDA 6.5 complains about not supporting gcc 4.9 - what to do?.
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. && make causes successful compilation.
Now another problem showed up: linking Google's libgflags or libprotobuf fails probably due to fact that it was compiled with newer gcc version but it's not related to asked question.
My machine runs Ubuntu 15.10, and my default compiler version is gcc 5.2.1 .
Commenting out the #error directive in line 115 of file
/usr/local/cuda-7.5/include/host_config.h
(or whatever the path on your system is) did the trick for me. Caffe compiled fine, all tests ran smoothly.
On the other hand, if one chooses to ignore this and proceed to compile part of the project with one compiler version, part of the project with another (for me it was gcc-4.8 and gcc-5.2.1), linking problems will arise. The linking problems of protobuf and libgflags another answer mentions are not unrelated to this.

Error compiling x264 on Mac OS X

I'm trying to compile and install the x264 H.264/AVC encoder.
I've got gcc installed. But I get the 'No working C compiler found' error when I run:
./configure --enable-shared --enable-static
What can I do?
The config log said:
/bin/gcc conftest.c -Wall -I. -I$(SRCPATH) -falign-loops=16 -mdynamic-no-pic -o conftest
clang: error: unknown argument: '-falign-loops=16' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
I encountered the same error and found a simple solution here:
http://www.xin.at/x264/x264-guide-macosx-en.htm
Before actually being able to start the build we will however need to remove a GCC compiler flag from the configure script, that the newer LLVM+CLANG compiler will not be able to handle. For that, please open the file configure in your favorite text editor and look for the following spot:
darwin*)
SYS="MACOSX"
CFLAGS="$CFLAGS -falign-loops=16"
Replace that with the following, effectively removing the -falign-loops=16 option:
darwin*)
SYS="MACOSX"
CFLAGS="$CFLAGS"
After doing the above, libx264 builds just fine :)
The configure script is trying to set a compiler option -falign-loops=16 that the clang compiler (masquerading as gcc) declines to accept.
Either get (compile) your own real GCC and use that (I've done the compilation and installation; it's not very hard, though neither is it trivial), or work out how to stop the configure script from failing simply because it assumes that the -falign-loops=16 option must be supported by all versions of GCC. That is the sort of thing the configure script should be checking so that you don't run into that sort of failure. Ultimately, this is a bug in the configuration for this code.

Resources