'rdkafka 0.8.1 ERROR: Failed to build gem native extension
I'm runnning bundle install
Then I get this error:
Fetching rdkafka 0.8.1
Installing rdkafka 0.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
Extracting v1.4.0 into tmp//ports/librdkafka/1.4.0... OK
Running 'configure' for librdkafka 1.4.0... ERROR, review '/Users/codegeek/.rvm/gems/ruby-2.5.1@ls-member/gems/rdkafka-0.8.1/ext/tmp/ports/librdkafka/1.4.0/configure.log' to see what happened. Last lines are:
========================================================================
source:
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
void foo (void) {
int s = socket(0, 0, 0);
close(s);
}
libpthread ()
module: self
action: fail
reason:
compile check failed:
CC: CC
flags: -lpthread
-g -O2 -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wall -Werror _mkltmpVFiBMn.c -o _mkltmpVFiBMn.c.o -lpthread:
mklove/modules/configure.base: line 1349: -g: command not found
source: #include <pthread.h>
But then it will suggest to do:
Make sure that `gem install rdkafka -v '0.8.1' --source 'https://rubygems.org/'` succeeds before bundling.
So I'll run gem install rdkafka -v '0.8.1' --source 'https://rubygems.org/'
but then
it will produce an error too
Building native extensions. This could take a while...
ERROR: Error installing rdkafka:
ERROR: Failed to build gem native extension.
Please help. Thanks!
Solution 1:[1]
I was able to fix it by providing the following compilation flags
CPPFLAGS=-I/usr/local/opt/openssl/include LDFLAGS=-L/usr/local/opt/openssl/lib gem install rdkafka -v '0.8.1'
I was able to find the answer in this GitHub issue
Hopefully that works for you!
Solution 2:[2]
just run the following on your terminal:
xcode-select --install
Solution 3:[3]
Based on @Luan answer I could fix my error. I have 2 homebrews installed which creates a mess in some occasions. If you are in an arm silicon macos try
CPPFLAGS=-I/opt/homebrew/opt/[email protected]/include/ LDFLAGS=-L/opt/homebrew/opt/[email protected]/lib gem install rdkafka -v '0.10.0'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Luan |
Solution 2 | Code Geek |
Solution 3 | frenesim |