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

Intro

Sharing storage (and get paid for) with Storj is pretty easy. As easy as:

1
2
3
4
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
$ nvm install --lts && nvm install --lts # not a typo, run it twice
$ export NVM_DIR="/home/storj/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
$ npm install --global storjshare-daemon

Anyway, with few boxes running Centos 6, installation process failed with cc1plus: error: unrecognized command line option "-std=c++11" error.

Issue

Installing storjshare-daemon on Centos/RHEL 6 with stock gcc/g++ will fail with cc1plus: error: unrecognized command line option "-std=c++11".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$ npm install --global storjshare-daemon
...
...
make: Entering directory `~/.nvm/versions/node/v8.9.4/lib/node_modules/storjshare-daemon/node_modules/diskusage/build'
CXX(target) Release/obj.target/diskusage/src/main.o
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [Release/obj.target/diskusage/src/main.o] Error 1
make: Leaving directory `~/.nvm/versions/node/v8.9.4/lib/node_modules/storjshare-daemon/node_modules/diskusage/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (~/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 2.6.32-573.7.1.el6.x86_64
gyp ERR! command "~/.nvm/versions/node/v8.9.4/bin/node" "~/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd ~/.nvm/versions/node/v8.9.4/lib/node_modules/storjshare-daemon/node_modules/diskusage
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! diskusage@0.2.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the diskusage@0.2.4 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/cc4f7e42-50c8-41e1-adb3-193c6704ac27-debug.log

About the System

1
2
3
4
5
6
7
8
$ cat /etc/redhat-release
CentOS release 6.9 (Final)

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)

$ g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)

Fix

Install GCC >= 4.7 in order to have support for -std=c++11 and -std=gnu++11 as well.

Centos/RHEL 6

1
2
3
4
5
6
7
8
9
10
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-3-toolchain
$ scl enable devtoolset-3 bash
$ gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

$ g++ --version
g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

$ npm install --global storjshare-daemon # should work now

Raspbian Wheezy

1
$ apt-get install gcc-4.8 g++-4.8

Happy “farming”.