question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instruct node-gyp to use specific version of g++ and gcc

See original GitHub issue

Hello,

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:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
bnoordhuiscommented, Dec 10, 2015

env CC=/path/to/gcc CXX=/path/to/g++ npm install should normally do the trick. If you want to use make_global_settings, you may have to set CC.host, CXX.host, CC.target and CXX.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.

0reactions
easwaraacommented, Dec 18, 2015

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving common issues with node-gyp - LogRocket Blog
Many node-gyp issues are actually issues with the toolchain used for building add-on code. We'll categorize these issues to offer solutions.
Read more >
NodeJS: node-gyp compile with the equivalent gcc -lm option
Solved. I've used the following binding.gyp and I've got a new version of the thirdy part library and it's working now! Thanks.
Read more >
node-gyp
Features: Easy to use, consistent interface; Same commands to build your module on every platform; Supports multiple target versions of Node. Installation.
Read more >
C++ addons | Node.js v19.3.0 Documentation
Developers who wish to use node-gyp directly can install it using the command npm install -g node-gyp . See the node-gyp installation instructions...
Read more >
node-gyp | Yarn - Package Manager
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It contains a vendored copy of the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found