node-rdkafka icon indicating copy to clipboard operation
node-rdkafka copied to clipboard

Failing to build on M1

Open gjbaxter opened this issue 3 years ago • 4 comments

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

  • OS [e.g. Mac, Arch, Windows 10]: Mac OSX 12.3.1
  • Node Version [e.g. 8.2.1]: 12.20.1
  • NPM Version [e.g. 5.4.2]: 6.14.10
  • C++ Toolchain [e.g. Visual Studio, llvm, g++]: seems to be using gcc.
  • node-rdkafka version [e.g. 2.3.3]: "^2.12.0"

Steps to Reproduce

node-rdkafka Configuration Settings

Additional context

gjbaxter avatar Apr 27 '22 20:04 gjbaxter

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)

cnault-twist avatar May 18 '22 22:05 cnault-twist

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

Kenadia avatar May 27 '22 21:05 Kenadia

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

This greatly helped.

mutebironald avatar Jun 23 '22 09:06 mutebironald

@gjbaxter where you able to solve the issue?

blastoy avatar Feb 22 '23 05:02 blastoy