Royal Pinto Royal Pinto - 1 month ago 17
C++ Question

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

Answer

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

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