Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are third party libraries included in native node.js modules?

Tags:

node.js

I'm working on a simple module for node.js in C/C++. The module depends on a third party (open source) C library that may or may not be installed on the machines my module can be compiled on.

My question is, how do I handle this dependency? Does the bindings.gyp offer some sort of mechanism I can use, shoud I just bundle it (if then, how?), or should I document my way out of it and inform users to install the library before compiling my module?

like image 494
fiskeben Avatar asked Nov 02 '22 17:11

fiskeben


1 Answers

You do this with targets in gyp:

https://code.google.com/p/gyp/wiki/GypUserDocumentation#Dependencies_between_targets

Example in a real module:

https://github.com/developmentseed/node-sqlite3/blob/7d763404079c47319f870ea1d11636517f1f0821/deps/sqlite3/sqlite3.gyp#L40-68

like image 72
Scott Avatar answered Nov 15 '22 04:11

Scott