librdkafka
librdkafka copied to clipboard
cmake build fix: link against libcurl explicilty
Encountered build errors on linux related to the linker not finding libcurl for some reason. It's fixed now.
Fix: Add explicit linking against libcurl in src/CMakeLists.txt
Error:
/home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:163: undefined reference to curl_easy_perform' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:167: undefined reference tocurl_easy_getinfo' /usr/bin/ld: ../src/librdkafka.a(rdhttp.c.o): in function rd_http_req_get_content_type': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:184: undefined reference tocurl_easy_getinfo' /usr/bin/ld: ../src/librdkafka.a(rdhttp.c.o): in function rd_http_post_expect_json': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:316: undefined reference tocurl_easy_setopt' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:317: undefined reference to curl_easy_setopt' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:319: undefined reference tocurl_easy_setopt' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:321: undefined reference to curl_easy_setopt' /usr/bin/ld: ../src/librdkafka.a(rdhttp.c.o): in functionrd_http_global_init': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:443: undefined reference to curl_global_init' /usr/bin/ld: ../src/librdkafka.a(rdkafka_sasl_oauthbearer_oidc.c.o): in functionrd_kafka_oidc_build_headers': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:116: undefined reference to curl_slist_append' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:117: undefined reference tocurl_slist_append' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:119: undefined reference to curl_slist_append' /usr/bin/ld: ../src/librdkafka.a(rdkafka_sasl_oauthbearer_oidc.c.o): in functionrd_kafka_oidc_token_refresh_cb': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:382: undefined reference to curl_slist_free_all' collect2: error: ld returned 1 exit status make[4]: *** [_deps/librdkafka-build/examples/CMakeFiles/producer.dir/build.make:103: _deps/librdkafka-build/examples/producer] Error 1 make[3]: *** [CMakeFiles/Makefile2:928: _deps/librdkafka-build/examples/CMakeFiles/producer.dir/all] Error 2/home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:163: undefined reference tocurl_easy_perform' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:167: undefined reference to curl_easy_getinfo' /usr/bin/ld: ../src/librdkafka.a(rdhttp.c.o): in functionrd_http_req_get_content_type': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:184: undefined reference to curl_easy_getinfo' /usr/bin/ld: ../src/librdkafka.a(rdhttp.c.o): in functionrd_http_post_expect_json': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:316: undefined reference to curl_easy_setopt' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:317: undefined reference tocurl_easy_setopt' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:319: undefined reference to curl_easy_setopt' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:321: undefined reference tocurl_easy_setopt' /usr/bin/ld: ../src/librdkafka.a(rdhttp.c.o): in function rd_http_global_init': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdhttp.c:443: undefined reference tocurl_global_init' /usr/bin/ld: ../src/librdkafka.a(rdkafka_sasl_oauthbearer_oidc.c.o): in function rd_kafka_oidc_build_headers': /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:116: undefined reference tocurl_slist_append' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:117: undefined reference to curl_slist_append' /usr/bin/ld: /home/adrian/repos/spoofy/build/_deps/librdkafka-src/src/rdkafka_sasl_oauthbearer_oidc.c:119: undefined reference tocurl_slist_append' /usr/bin/ld: ../src/librd
Tested the patch at Arch Linux and it works for me
Should curl be also added in Requires field in pkgconfig file?
Will this be merged? Just got a failed build again on a clean pull of the rdkafka dependency before my master's thesis presentation and nearly had a heart attack. Luckily I remembered and added it manually again, but would appreciate not having to do so in the future.
Hi @edenhill, can this be merged please? In our pipeline we have to use sed to add these lines to the CMakeLists.txt which is not ideal.
@adriancostin6 Did you see @stertingen 's suggestion?
Fixed in #4003
@edenhill can't be surprised I forgot about this since it's been ignored for months on end 😁 thx for merging the fix and all the work you've done on the lib. maybe i'll put some more fixes in the future to contribute.