confluent-kafka-go: Package rdkafka was not found in the pkg-config search path.

Description

[root@localhost librdkafka]# go get -u github.com/confluentinc/confluent-kafka-go/kafka

pkg-config --cflags rdkafka

Package rdkafka was not found in the pkg-config search path. Perhaps you should add the directory containing `rdkafka.pc’ to the PKG_CONFIG_PATH environment variable No package ‘rdkafka’ found pkg-config: exit status 1

anything missing ? on centos

How to reproduce

Checklist

Please provide the following information:

  • confluent-kafka-go and librdkafka version (LibraryVersion()):
  • Apache Kafka broker version:
  • Client configuration: ConfigMap{...}
  • Operating system:
  • Provide client logs (with "debug": ".." as necessary)
  • Provide broker log excerpts
  • Critical issue

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

brew install librdkafka

It seems the pkg-config problem, need to specify the searching path manually .

  1. find the position of your “rdkafka.pc” file, In my centos it’s /usr/lib/pkgconfig/

2.add the env variable to the file ~/.bash_profile export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig/

3.source ~/.bash_profile and restart the terminal

4.then,go get -u github.com/confluentinc/confluent-kafka-go/kafka works

It works for me. env: centos 7

having the same issue, it works on my system. Upon deployment there is the same error

Edit: @woshidama323 answer: apt-get install pkg-config export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig/ seems to do the trick

@imans777 Your librdkafka is too old, in fact it seems that you have multiple versions of librdkafka installed. Remove all versions of librdkafka on your system, then install v1.1.0 or later through the Confluent Platform APT/RPM repositories or build librdkafka from source and install.

The upcoming version of confluent-kafka-go will come with librdkafka prebuilt and bundled.

Exactly the same issue there on VS Code and Windows 10 64. “For Windows, see the librdkafka.redist NuGet package.” instruction didn’t make life easier. Whole internet is full of questions on how to get pkg-config and confluent working in Windows, but no clear instructions are provided. Could be great to provide CRYSTAL CLEAR step by step setup instruction for Windows Go developers in package documentation. BTW - this helped for me on Windows - Some Blog

In mac os with m1,

arch -arm64 brew install librdkafka pkg-config
brew install libressl
export PKG_CONFIG_PATH="/opt/homebrew/opt/libressl/lib/pkgconfig"

If you need to have libressl first in your PATH, run: echo ‘export PATH=“/opt/homebrew/opt/libressl/bin:$PATH”’ >> ~/.zshrc

For compilers to find libressl you may need to set: export LDFLAGS=“-L/opt/homebrew/opt/libressl/lib” export CPPFLAGS=“-I/opt/homebrew/opt/libressl/include”

@edenhill Yeah I figured it out right after I posted that comment 😃 Because I tried apt-get and weren’t successful and I tried installing from binary but I took the master branch and it wasn’t the latest version. So I checked out to v1.2.0 and tried installing from binary again and everything worked as expected!

Thanks and sorry!