Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-gyp link library dependencies at build time

My nodejs addon uses cares library and my binding.gyp has dependencies attribute which is pointing to this. Now whenever I have to run addon, I have to export LD_LIBRARY_PATH variable.

Is there a way I can configure this in binding.gyp so that every time I don't have to set LD_LIBRARY_PATH. (Linking at build time)

Dependency setting in binding.gyp: "dependencies": [ "deps/cares/cares.gyp:cares" ]

Ex export: export LD_LIBRARY_PATH=build/Release

like image 623
Royal Pinto Avatar asked Apr 21 '15 13:04

Royal Pinto


2 Answers

"libraries": [ "-Wl,-rpath,./build/Release/" ]

Worked for me on Mac as well as Linux(Ubuntu).

like image 105
Royal Pinto Avatar answered Sep 19 '22 04:09

Royal Pinto


My answer to how to add dependence to static library in binding.gyp node-gyp for node.js extension seems to apply here as well, and should be cross platform.

In short it uses the module_root_dir and builds an absolute path. Example:

"libraries": [
    "-lcares",
    "-L<(module_root_dir)/build/Release/"
]
like image 37
Ale Avatar answered Sep 19 '22 04:09

Ale