使用cmake 编译libkafka静态库问题
wget https://github.com/confluentinc/librdkafka/archive/refs/tags/v2.2.0.zip
unzip v2.2.0.zip
cd librdkafka-2.2.0
chmod 777 configure lds-gen.py
./conconfigure
vim Makefile.config
make
sudo make install
pkg-config --libs --static rdkafka++-static
-L/usr/local/lib //usr/local/lib/librdkafka++.a -lm -ldl -lpthread -lrt -lpthread -lrt //usr/local/lib/librdkafka.a -lm -ldl -lpthread -lrt -lpthread -lrt -lz -lssl -lcrypto -ldl -pthread
1.cmake编译出现 undefined reference to symbol “dlcloseglibc”
target_link_libraries()中添加 ${CMAKE_DL_LIBS}
2.undefined undefined reference to XXX
libkafka的静态库在编译时需要依赖库的静态库,
运行pkg-config --libs --static rdkafka++-static 获取需要依赖的库
把需要的静态库文件加入到cmake的target_link_libraries中