如何根据具有相对位置的共享库构buildnodejs C ++插件
我正在尝试使用node-gyp
构buildnode.js C ++,但无法弄清楚如何指定-Wl,-rpath,$ORIGIN
以便在从节点加载时可以find相同的共享对象库目录作为addon.node
。
我已经尝试设置我的binding.gyp
像这样:
"libraries": [ "-L../../install_release_x64/", "-llibppp" ], "ldflags": [ "-Wl,-rpath,'$ORIGIN'" ], "cflags_cc": [ "-fexceptions", "-fPIC", "-Wno-unknown-pragmas" ]
但是当我运行$ readelf -d addon.node
的结果是这样的:
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
预期的结果是Library rpath: [$ORIGIN]
任何想法node-gyp对我的$ORIGIN
特殊关键字做什么?
看起来像我必须这样逃避它:
"ldflags": [ "-Wl,-rpath,'$$ORIGIN'" ],
现在它像预期的那样工作。