librdkafka icon indicating copy to clipboard operation
librdkafka copied to clipboard

cmake build fix: link against libcurl explicilty

Open adriancostin6 opened this issue 3 years ago • 4 comments

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

adriancostin6 avatar Jul 13 '22 15:07 adriancostin6

Tested the patch at Arch Linux and it works for me

anatol avatar Jul 13 '22 17:07 anatol

Should curl be also added in Requires field in pkgconfig file?

Biswa96 avatar Jul 17 '22 04:07 Biswa96

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.

adriancostin6 avatar Sep 01 '22 09:09 adriancostin6

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.

Sean2108 avatar Sep 23 '22 14:09 Sean2108

@adriancostin6 Did you see @stertingen 's suggestion?

edenhill avatar Oct 03 '22 12:10 edenhill

Fixed in #4003

edenhill avatar Nov 02 '22 08:11 edenhill

@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.

adriancostin6 avatar Nov 02 '22 23:11 adriancostin6