概述
librdkafka是Apache Kafka协议的C库实现,提供Producer、Consumer和Admin客户端。
- librdkafka开源库的地址
https://github.com/confluentinc/librdkafka
- librdkafka依赖的第三方库
- zlib-dev
# 方式一:直接安装zlib
apt install zlib-dev
apt install zlib1g
apt install zlib1g.dev
# 方式二:源码编译安装
git clone https://github.com/madler/zlib.git
./configure
make -j4
make install
- libzstd-dev
git clone https://github.com/facebook/zstd.git
make -j4
make install
- libssl-dev
apt install libssl-dev
- libsasl2-dev
apt install libsasl2-dev
- libcurl-dev
apt install libcurl-dev
# 选择以下三个任意一个安装(选择第一个最优)
libcurl4-openssl-dev
libcurl4-nss-dev
libcurl4-gnutls-dev
apt install libcurl4-openssl-dev
- 编译librdkafka库
git clone https://github.com/confluentinc/librdkafka.git
mkdir build
# 查看配置帮
./configure -h
./configure --prefix=./build --enable-shared --enable-zlib --enable-ssl --enable-sasl --enable-zstd --enable-curl
make -j4
make install
在build目录生成的文件如图:
- include目录
- lib目录
- 笔者采用的Linux系统和编译工具信息
gcc -v
gcc version 7.5.0
g++ -v
g++ version 7.5.0
make -v
GNU Make 4.1
git --version
git version 2.17.1
# librdkafka的版本
librdkafka-1.9.2