The -std = gnu ++ 0x option for MacOS

I am trying to compile a CMake project that uses

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -std=gnu++0x") 

in the CMakeLists.txt file for MacOS X Lion. I installed Xcode 4.2.1. but the compiler does not cope with this:

 cd something/src/lib && /usr/bin/c++ -Dlib_ginacra_EXPORTS -Wall -std=gnu++0x -fPIC -o CMakeFiles/lib_ginacra.dir/utilities.cpp.o -c something/src/lib/utilities.cpp cc1plus: error: unrecognized command line option "-std=gnu++0x" 

Compiler Domain:

 c++ --version i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) 
+4
source share
3 answers

GCC 4.2 is ancient, but Apple is not sending a newer version.

You can install modern GCC from somewhere like Mac Ports (which is probably simpler and faster) or create it yourself by following the instructions at http://gcc.gnu.org/wiki/InstallingGCC

+7
source

Lion users are facing this problem:

Download and install MacPorts MacPorts-2.2.1-10.7-Lion.pkg . installation package from here

in the terminal, search for new versions of GCC:

 $ port search --name --glob 'gcc*' 

install a newer version (I went with gcc5)

 $ sudo port install gcc5 

get the name of your new version and set it as the default

 $ port select --list gcc Available versions for gcc: llvm-gcc42 mp-gcc5 none (active) $ sudo port select --set gcc mp-gcc5 

open a new terminal and confirm that you are updated:

 $ c++ --version c++ (MacPorts gcc5 5.2.0_0) 5.2.0 
0
source

Most of you get this error β€œcc1plus: error: unrecognized command line option -std = gnu ++ 0x” when installing nodejs extension, which requires compiling C ++ with node -gyp . So how to solve this error, so here is the solution. You mostly get these errors due to the different version of Nodejs, since many node libraries require C or C ++ to be compiled during installation. Thus, the earlier version of Nodejs uses python 2.7 with the gcc compiler less than version 4.2, but the newer version of Nodejs uses the gcc44 compiler, so you get higher errors when installing any nodejs library.

So, you need to degrade the version of nodejs and node -gyp and specify the python version if you have several python versions installed on your system and you no longer get the above error.

Click here to view the full tutorial.

-1
source

Source: https://habr.com/ru/post/1411084/


All Articles