HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.16k stars 684 forks source link

Undefined references to CURL functions #856

Open 370rokas opened 2 weeks ago

370rokas commented 2 weeks ago

Hey, I am getting linker errors to libCurl functions.

/usr/bin/ld: /home/rokas/Documents/CLionProjects/scm-scraper/build/libdate-tz.so.3.0.3: undefined reference to `curl_global_init@CURL_OPENSSL_4'
/usr/bin/ld: /home/rokas/Documents/CLionProjects/scm-scraper/build/libdate-tz.so.3.0.3: undefined reference to `curl_easy_perform@CURL_OPENSSL_4'
/usr/bin/ld: /home/rokas/Documents/CLionProjects/scm-scraper/build/libdate-tz.so.3.0.3: undefined reference to `curl_easy_setopt@CURL_OPENSSL_4'
/usr/bin/ld: /home/rokas/Documents/CLionProjects/scm-scraper/build/libdate-tz.so.3.0.3: undefined reference to `curl_easy_init@CURL_OPENSSL_4'
/usr/bin/ld: /home/rokas/Documents/CLionProjects/scm-scraper/build/libdate-tz.so.3.0.3: undefined reference to `curl_easy_cleanup@CURL_OPENSSL_4'
/usr/bin/ld: /home/rokas/Documents/CLionProjects/scm-scraper/build/libdate-tz.so.3.0.3: undefined reference to `curl_global_cleanup@CURL_OPENSSL_4'

This is my CMake code for getting the library:

set(BUILD_TZ_LIB ON)
FetchContent_Declare(
        date_src
        GIT_REPOSITORY https://github.com/HowardHinnant/date.git
        GIT_TAG        v3.0.3
)
FetchContent_MakeAvailable(date_src)

target_link_libraries(scm-scraper PRIVATE
        date::date-tz
        date::date
        ....
)

I am running:

Arch Linux 6.11.4-arch1-1
GCC 14.2.1 20240910
CMake 3.30.5
curl 8.10.1 (x86_64-pc-linux-gnu) libcurl/8.10.1 OpenSSL/3.3.2 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.64.0 nghttp3/1.6.0

Any clue what might be wrong with my system's configuration?

Best Regards

HowardHinnant commented 2 weeks ago

I'm a CMake flunky. So if you find a fix to the CMake build system that fixes this, I'm open to a patch.

Meanwhile I like to build without CMake. Here are the instructions I follow: https://howardhinnant.github.io/date/tz.html#Installation

Adding -lcurl to your compile/link command will fix this. Here is my complete typical build command:

clang++ -std=c++17 test.cpp -I../date/include ../date/src/tz.cpp -O3 -lcurl