curlpp icon indicating copy to clipboard operation
curlpp copied to clipboard

Build error (cannot find curl)

Open arietto opened this issue 5 years ago • 4 comments

I use C++, curl 7.64, CMake 3.19.3, curlpp 0.8.1, Windows 7 OS. I cannot build curlpp out-of-the-box. CURL_FOUND is set to true, but CURL_INCLUDE_DIRS and CURL_LIBRARIES are empty (AFAIK, CMake module delegates variables filling to curl CMake module).

I've set CURL_INCLUDE_DIRS manually, but setting CURL_LIBRARIES="debug "path_to_debug" optimized "path_to_release"" fails. So, I've got linker errors.

BTW, why do some curl-consuming CMakeLists.txt files use ${CURL_LIBRARIES} and the other ones use CURL::libcurl for feeding target_link_libraries? I suppose that curlpp uses obsolete way to connect to curl. P.S. When I switched to CURL::libcurl, then the build was successful. AFAIK, CURL_INCLUDE_DIRS becomes redundant in that mode.

arietto avatar Jan 20 '21 11:01 arietto

Hi,

did you try to just set CURL_LIBRARY to libcurl :

set(CURL_LIBRARY libcurl)

sgallou avatar Jan 20 '21 12:01 sgallou

Where should I put this command? I've tried to set it as a command line argument (-DCURL_LIBRARY=libcurl) for curlpp, but build failed. Putting set(CURL_LIBRARY libcurl) to the top of curlpp CMakeLists.txt did not help either.

arietto avatar Jan 20 '21 14:01 arietto

I put it in the CMakeLists.txt of my project, before to call add_subdirectory on the curlpp directory. Here is part of my CMakeLists.txt :

set(CURL_INCLUDE_DIR ${CURL_SOURCE_DIR}/include)
set(CURL_LIBRARY libcurl)
set(CURLPP_BUILD_SHARED_LIBS OFF)
add_subdirectory(curlpp-0.8.1)

As I use static build, my app need to be linked to libcurl and curlpp_static.

sgallou avatar Jan 20 '21 14:01 sgallou

Thank you. But what if somebody wants to build dynamic library? I don't understand why manual patching of CMakeLists.txt is required. curlpp should be built out-of-the-box.

arietto avatar Jan 20 '21 17:01 arietto