Blizzard / node-rdkafka

Node.js bindings for librdkafka
MIT License
2.11k stars 396 forks source link

Failing to build on M1 #950

Open gjbaxter opened 2 years ago

gjbaxter commented 2 years ago

Trying to do an npm install of node-rdkafka.

I've brew installed openssl, librdkafka and set the env variables

LDFLAGS=-L/opt/homebrew/opt/openssl@3/lib CPPFLAGS=-I/opt/homebrew/opt/openssl@3/include PKG_CONFIG_PATH=/opt/homebrew/opt/openssl@3/lib/pkgconfig

During the build, I'm seeing this problem:

ld: warning: ignoring file /opt/homebrew/Cellar/lz4/1.9.3/lib/liblz4.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/openssl@3/lib/libssl.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/openssl@3/lib/libcrypto.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

So I suspect it's ignoring the crypto library, for example, and thus failing with a bunch of missing symbol errors... e.g.:

Undefined symbols for architecture x86_64: "_BIO_ctrl", referenced from: _rd_kafka_conf_set_ssl_cert in rdkafka_cert.o "_BIO_free", referenced from: _rd_kafka_conf_set_ssl_cert in rdkafka_cert.o _rd_kafka_ssl_ctx_init in rdkafka_ssl.o "_BIO_new_mem_buf", referenced from: _rd_kafka_conf_set_ssl_cert in rdkafka_cert.o _rd_kafka_ssl_ctx_init in rdkafka_ssl.o "_CRYPTO_free", referenced from: _rd_kafka_transport_ssl_cert_verify_cb in rdkafka_ssl.o ... and on and on

I'm wondering why it's trying to build for x86_64.. and indeed earlier it says

Configuration summary: prefix /Users/gjbaxter/dev/xxx/platform/node_modules/node-rdkafka/build/deps MKL_DISTRO osx SOLIB_EXT .dylib ARCH x86_64 CPU generic ... LDFLAGS -L/opt/homebrew/opt/openssl@3/lib -L/Users/gjbaxter/dev/xxx/platform/node_modules/node-rdkafka/build/deps CC gcc CXX g++ CPPFLAGS -I/opt/homebrew/opt/openssl@3/include -gstrict-dwarf -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align

Environment Information

Steps to Reproduce

node-rdkafka Configuration Settings

Additional context

cnault-twist commented 2 years ago

Someone on my team also seems to have issue installing via npm on their M1 Mac (We included the normal Mac OX X compiler flags but still has issues. It seems to be unique to the M1 Macs)

Kenadia commented 2 years ago

I had the same errors and switching from node 14 to node 16 fixed this for me

mutebironald commented 2 years ago

I had the same errors and switching from node 14 to node 16 fixed this for me

This greatly helped.

blastoy commented 1 year ago

@gjbaxter where you able to solve the issue?