morganstanley / modern-cpp-kafka

A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)
Apache License 2.0
348 stars 88 forks source link

confusion about using head only file #160

Closed hazy-wu closed 2 years ago

hazy-wu commented 2 years ago

hi dear authors, thanks for your job! I got some error when I use include/kafka's head only file. I have a cmake project and copy a example file as my main.cpp, then I write the below

add_executable(kafka main.cpp)

target_include_directories(kafka PUBLIC ../../../third_party/modern-cpp-kafka/include)

target_link_libraries(kafka INTERFACE rdkafka pthread)

to my CMakeLists.txt. But when I run my main.cpp I got some error like undefined reference to 'rd_kafka_conf_destroy'. I think it's a link not found problem so I debug cmake but it show that there are rdkafka and pthread lib in my env. I m confused about it and I wanna asking for your help~ Or Could you tell me how to use it correctly?