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

With reference to issue #481, the suggested solution fails with 'fatal error: 'rdkafkacpp.h' file not found'

Open SomalRudra opened this issue 3 years ago • 6 comments

Environment Information

  • OS [Mac M1]:
  • Node Version [v14.17.5]:
  • NPM Version [6.14.14]:
  • C++ Toolchain [Visual Studio]:

Steps to Reproduce npm install node-rdkafka

Additional context While trying to install node-rdkafka, faced this issue & tried the solution, but now there's a linking issue.

The error states:

~/node_modules/node-rdkafka/src/binding.h:15:10: fatal error: 'rdkafkacpp.h' file not found #include "rdkafkacpp.h" ^~~~~~~~~~~~~~

SomalRudra avatar Feb 11 '22 10:02 SomalRudra

I am facing the same issue on my 2021 M1 MacBook Pro. I had tried to install the normal way of

export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"

npm install node-rdkafka

and receive the following error ld: symbol(s) not found for architecture x86_64 which is understandable since this is an M1. That led me to try

brew install librdkafka

BUILD_LIBRDKAFKA=0 npm install node-rdkafka

and resulting in the missing header error.

jbkuczma avatar Feb 11 '22 13:02 jbkuczma

Same exact issue.

raminnoodle avatar Feb 20 '22 04:02 raminnoodle

I faced the same issue. This is because for M1 chip, librdkafka is installed under /opt/homebrew/Cellar, and for Intel Mac, it's under /usr/local/Cellar. For some reason, node-rdkafka assumes you're using Intel chip and looks for rdkafkacpp.h under /usr/local/Cellar path, which is empty if you use ARM terminal.

The solution that works for me:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Install librdkafka for Intel: /usr/local/bin/brew install librdkafka
  • Go back to your ARM terminal, try npm install again, it should be successful.

davidnd avatar Mar 23 '22 05:03 davidnd

THANK YOU! Iv spent over a month off and on trying to get this to work on my local machine. For anyone also needingopenssl run this after your install librdkafka (for intel) run /usr/local/bin/brew install openssl

Then in the ARM terminal run the lines below. export CPPFLAGS="-I/usr/local/opt/openssl@3/include" export LDFLAGS="-L/usr/local/opt/openssl@3/lib" npm install

raminnoodle avatar Mar 23 '22 21:03 raminnoodle

I am facing the same issue on my 2021 M1 MacBook Pro. I had tried to install the normal way of

export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"

npm install node-rdkafka

and receive the following error ld: symbol(s) not found for architecture x86_64 which is understandable since this is an M1. That led me to try

brew install librdkafka

BUILD_LIBRDKAFKA=0 npm install node-rdkafka

and resulting in the missing header error.

To solve this in my case, I had to install the homebrew x86 version to allow me to install the lz4 with x86 architecture. You can install homebrew x86 by following this guideline.

After this all I had to do when performing npm install, is to tell the GCC compiler: “Hey, please utilize the x86 version of the lz4”. You can accomplish this by informing the lz4 x86 path in the LDFLAGS (gcc known env variable) In my case I did:

LDFLAGS="-L/usr/local/homebrew/Cellar/lz4/1.9.3/lib" npm i

Relates to #481

Saeger avatar Apr 20 '22 17:04 Saeger

# ➜ ln -s /opt/homebrew/opt/openssl /usr/local/opt/openssl export BUILD_LIBRDKAFKA=0 export LIBRARY_PATH="/opt/homebrew/Cellar/librdkafka/2.3.0/lib" export CPLUS_INCLUDE_PATH="/opt/homebrew/Cellar/librdkafka/2.3.0/include/librdkafka"

WhiteKiwi avatar Apr 23 '24 05:04 WhiteKiwi