Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SomalRudra opened this issue Feb 11, 2022 · 6 comments

Comments

@SomalRudra
Copy link

SomalRudra commented Feb 11, 2022

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"
^~~~~~~~~~~~~~

@jbkuczma
Copy link

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.

@raminnoodle
Copy link

Same exact issue.

@davidnd
Copy link

davidnd commented Mar 23, 2022

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.

@raminnoodle
Copy link

raminnoodle commented Mar 23, 2022

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

@Saeger
Copy link

Saeger commented Apr 20, 2022

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

@WhiteKiwi
Copy link

WhiteKiwi commented Apr 23, 2024

# ➜ 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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants