node-gyp link library dependencies at build time

Royal Pinto picture Royal Pinto · Apr 21, 2015 · Viewed 8k times · Source

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

Royal Pinto picture Royal Pinto · Apr 30, 2015

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

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