I am writing a C++ addon for Nodejs which uses OpenSSL 3 and I keep getting this error when trying to compile the code with the command 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"
I can see that the OpenSSL used here is included from the NodeJS folder, is there any way to link the OpenSSL library I installed with homebrew on my mac M1?
My binding.gyp file looks like this:
{
"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"
]
}
]
}
This is a problem in Node.js: https://github.com/nodejs/node/issues/40575
And here is a workaround: https://github.com/mmomtchev/node-gdal-async/commit/85816cbeff104b5484aae840fe43661c16cb6032
Add those two defines to your gyp:
"OPENSSL_API_COMPAT=0x10100001L",
"OPENSSL_CONFIGURED_API=0x30000000L"
I am the author of both the issue and the workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With