【问题标题】:How to build nodejs C++ addon depending on a shared library with relative location如何根据具有相对位置的共享库构建nodejs C++插件
【发布时间】:2017-02-28 23:41:18
【问题描述】:

我正在尝试使用 node-gyp 构建 node.js C++,但不知道如何指定 -Wl,-rpath,$ORIGIN,以便从节点加载时它可以找到与相同目录中的共享对象库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 特殊关键字做了什么吗?

【问题讨论】:

    标签: node.js gcc node-modules node-gyp compiler-flags


    【解决方案1】:

    看起来我必须像这样逃避它:

    "ldflags": [
        "-Wl,-rpath,'$$ORIGIN'"
    ],
    

    现在它可以正常工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-29
      • 1970-01-01
      • 1970-01-01
      • 2015-03-05
      相关资源
      最近更新 更多