如何根据具有相对位置的共享库来构建Node.js C ++插件 [英] How to build nodejs C++ addon depending on a shared library with relative location
本文介绍了如何根据具有相对位置的共享库来构建Node.js C ++插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用node-gyp
构建node.js C ++,但无法弄清楚如何指定-Wl,-rpath,$ORIGIN
,以便从节点加载时可以找到与该目录位于同一目录中的共享库. addon.node
.
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
.
我尝试这样设置binding.gyp
:
"libraries": [
"-L../../install_release_x64/",
"-llibppp"
],
"ldflags": [
"-Wl,-rpath,'$ORIGIN'"
],
"cflags_cc": [
"-fexceptions",
"-fPIC",
"-Wno-unknown-pragmas"
]
但是当我运行$ readelf -d addon.node
时,结果是这样的:
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
预期结果为Library rpath: [$ORIGIN]
有什么想法,node-gyp对我的$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.
这篇关于如何根据具有相对位置的共享库来构建Node.js C ++插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文