Instruct node-gyp to use specific version of g++ and gcc
See original GitHub issueHello,
I am new to the world of installing Javascript modules and I am having the task of installing capnp JS libraries using g++ v4.8 in our RHEL6 environment.
As we only have v4.4.7 in /usr/bin/g++, we decided to use the g++ (v4.8.2) installed in /opt.
I downloaded the source from https://github.com/kentonv/node-capnp and added the below lines to binding.gyp but it doesn’t work.
'make_global_settings': [
{
'CXX': ['/opt/rh/devtoolset-2/root/usr/bin/g++'],
'CC': ['/opt/rh/devtoolset-2/root/usr/bin/gcc']
}],
When I straced the process, found that node-gyp is looking for the g++ libraries only in below location.
/usr/lib/node_modules/npm/bin/node-gyp-bin
/u/easwaraa/node_modules/capnp/node_modules/.bin
/usr/bin
I tried searching around to see if I can update the path somewhere but couldn’t find it. FWIW, I tried updating my .pathrc too but it didn’t help.
When I run npm install, I get the below message.
~/tmp/capnproto/temp_js_RPC/node-capnp $ npm install
> capnp@0.1.11 install /u/easwaraa/tmp/capnproto/temp_js_RPC/node-capnp
> node ./build.js
make: Entering directory `/u/easwaraa/tmp/capnproto/temp_js_RPC/node-capnp/build'
CXX(target) Release/obj.target/capnp/src/node-capnp/capnp.o
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [Release/obj.target/capnp/src/node-capnp/capnp.o] Error 1
make: Leaving directory `/u/easwaraa/tmp/capnproto/temp_js_RPC/node-capnp/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Linux 2.6.32-573.8.1.el6.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /u/easwaraa/tmp/capnproto/temp_js_RPC/node-capnp
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v0.10.6
gyp ERR! not ok
Build failed
npm ERR! weird error 1
npm ERR! not ok code 0
How can I update node-gyp to use the different version of g++?
Please let me know if something isn’t clear.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:12 (6 by maintainers)
env CC=/path/to/gcc CXX=/path/to/g++ npm install
should normally do the trick. If you want to usemake_global_settings
, you may have to setCC.host
,CXX.host
,CC.target
andCXX.target
as well.It looks like you’re using devtoolset-2; it’s been a while since I last worked with that but I remember you need to start a shell with
scl enable
for it to be active.This is what I have in the “main” filed in package.json.
“main”: “src/node-capnp/capnp.js”, “peerDependencies”: { “es6-promise”: “1.x” },
Let me try to write some test JS code by using this module and see if it works. Thanks 😃