gpt4 book ai didi

c++ - 将本地 Openssl 链接到 Nodejs C++ 插件

转载 作者:行者123 更新时间:2023-12-05 04:38:43 25 4
gpt4 key购买 nike

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

/Users/myuser/Library/Caches/node-gyp/17.0.1/include/node/openssl/macros.h:155:4: 错误:“OPENSSL_API_COMPAT 表示不可能的 API 兼容性级别”

我可以看到这里使用的 OpenSSL 包含在 NodeJS 文件夹中,有什么方法可以链接我在 mac M1 上用自制软件安装的 OpenSSL 库吗?

我的 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"
]
}
]
}

最佳答案

这是 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"

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

关于c++ - 将本地 Openssl 链接到 Nodejs C++ 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70541687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com