Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to instruct CMake to find specific version of Curl

I have built Curl from source and it’s installed in /usr/local/lib/libcurl.so

I am now trying to instruct CMake to statically link this version with my application (if dynamic is easier, that’s fine).

From other Stackoverflow questions I tried this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

option(CURL_STATICLIB "Set to ON to build libcurl with static linking."  ON)
option(LIBCURL_ENABLE "Enable or disable the requirement of libcurl" ON)

set(CURL_LIBRARY "-lcurl") 
set(CURL_PATH "/usr/local/lib")

find_library(LIB_CURL NAMES libcurl PATHS ${CURL_PATH})

include_directories(${CURL_INCLUDE_DIR})
message(STATUS "LIB_CURL: " ${LIB_CURL})

add_definitions(-DCURL_STATICLIB)
target_link_libraries(my_project PRIVATE ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES})

but it cannot find libcurl.so:

LIB_CURL: LIB_CURL-NOTFOUND

(My CMake knowledge is basic, any additional tips to improve the above are welcome)

>Solution :

option(CURL_STATICLIB "Set to ON to build libcurl with static linking."  ON)
option(LIBCURL_ENABLE "Enable or disable the requirement of libcurl" ON)

option is used wrongly. curl is not configured in that CMakeLists, therefore option should be removed.

Try

find_library(LIB_CURL NAMES curl PATHS ${CURL_PATH})

It’s unclear, you define -DCURL_STATICLIB but look for libcurl.so

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading