nodejs addon uses
cares library and my
dependencies attribute which is pointing to this. Now whenever I have to run
addon, I have to export
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" ]
"libraries": [ "-Wl,-rpath,./build/Release/" ]
Worked for me on Mac as well as Linux(Ubuntu).
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.
"libraries": [ "-lcares", "-L<(module_root_dir)/build/Release/" ]
I have had success obtaining a relative path in Ubuntu & Debian using the following
"libraries": [ "../lib/somelib/somelib.a" ]
My folder structure looks like this:
|--binding.gyp |--app.cc |--lib |--somelib |--somelib.a
I got the method (somewhat indirectly) from here: