I'm trying to build a node.js C++ using node-gyp
but can't figure out how to specify the -Wl,-rpath,$ORIGIN
so that when loaded from node it could find shared object library that is in the same directory as addon.node
.
I have tried setting my binding.gyp
like this:
"libraries": [
"-L../../install_release_x64/",
"-llibppp"
],
"ldflags": [
"-Wl,-rpath,'$ORIGIN'"
],
"cflags_cc": [
"-fexceptions",
"-fPIC",
"-Wno-unknown-pragmas"
]
but when I run $ readelf -d addon.node
the result is like this:
Dynamic section at offset 0x7d10 contains 29 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [liblibppp.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname: [addon.node]
0x000000000000000f (RPATH) Library rpath: [RIGIN]
0x000000000000000c (INIT) 0x37a0
The expected result is Library rpath: [$ORIGIN]
Any ideas what's node-gyp doing to my $ORIGIN
special keyword?
Looks like I have to escape it like this:
"ldflags": [
"-Wl,-rpath,'$$ORIGIN'"
],
Now it works like expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With