【问题标题】:Linking local Openssl to Nodejs C++ addon将本地 Openssl 链接到 Nodejs C++ 插件
【发布时间】:2021-12-31 11:11:25
【问题描述】:

我正在为使用 OpenSSL 3 的 Nodejs 编写 C++ 插件,但在尝试使用命令 node-gyp build 编译代码时,我不断收到此错误:

/Users/myuser/Library/Caches/node-gyp/17.0.1/include/node/openssl/macros.h:155:4: error: "OPENSSL_API_COMPAT expresses an impossible API compatibility level"

我可以看到这里使用的 OpenSSL 包含在 NodeJS 文件夹中,有什么方法可以将我安装的 OpenSSL 库与我的 mac M1 上的 homebrew 链接起来?

我的 binding.gyp 文件如下所示:

{
  "targets": [
    {
      "target_name": "module",
      "include_dirs": [ "/opt/homebrew/opt/openssl@3/include" ],
      "sources": [ "./module.cpp" ],
      "libraries": [
            "/opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib",
            "/opt/homebrew/opt/openssl@3/lib/libcrypto.a",
            "/opt/homebrew/opt/openssl@3/lib/libcrypto.dylib"
        ]
    }
    ]
}

【问题讨论】:

    标签: c++ node.js openssl


    【解决方案1】:

    这是 Node.js 中的一个问题:https://github.com/nodejs/node/issues/40575

    这里有一个解决方法:https://github.com/mmomtchev/node-gdal-async/commit/85816cbeff104b5484aae840fe43661c16cb6032

    将这两个定义添加到您的 gyp:

    "OPENSSL_API_COMPAT=0x10100001L",
    "OPENSSL_CONFIGURED_API=0x30000000L"
    

    我是问题和解决方法的作者。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 2014-02-12
      相关资源
      最近更新 更多