Setting curl library path in cmake

I downloaded the curl library for use with a third-party application. When I run the included cmake file, I get the following error. Please help me. I appreciate it:

> The C compiler identification is MSVC 18.0.30501.0 > The CXX compiler identification is MSVC 18.0.30501.0 > Check for working C compiler using: Visual Studio 12 2013 > Check for working C compiler using: Visual Studio 12 2013 -- works > Detecting C compiler ABI info > Detecting C compiler ABI info - done > Check for working CXX compiler using: Visual Studio 12 2013 > Check for working CXX compiler using: Visual Studio 12 2013 -- works > Detecting CXX compiler ABI info > Detecting CXX compiler ABI info - done > Could NOT find CURL (missing: CURL_LIBRARY) (found version "7.38.0") > CMake Error at CMakeLists.txt:49 (MESSAGE): > Could not find the CURL library and development files. > > Configuring incomplete, errors occurred! > See also "C:/BUILD/CMakeFiles/CMakeOutput.log". 

I set the environment variable for "CURL_LIBRARY" on Windows to indicate where the curl library files should be installed, but cmake still cannot find it, even if it indicates that version 7.38.0 was detected on my system.

Thanks for the help.

EDIT: cMakeLists.txt File

  ... # Look for required libraries SET(requiredlibs) FIND_PACKAGE(CURL) IF(CURL_FOUND) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR}) SET(requiredlibs ${requiredlibs} ${CURL_LIBRARIES} ) ELSE(CURL_FOUND) MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.") ENDIF(CURL_FOUND) ... 

I set include and lib dirs to the windows environment variable, but no change.

EDIT: this is the complete project file: cmake project .

+5
source share
1 answer

I had the same issue and this SO question was one of the best during my search. Therefore, I give the solution that I found. After cmake worked for me to use libcurl, include in my code. Hope this will be helpful to someone.

 set(CURL_LIBRARY "-lcurl") find_package(CURL REQUIRED) add_executable (curl-demo convert.cpp) include_directories(${CURL_INCLUDE_DIR}) target_link_libraries(curl-demo ${CURL_LIBRARIES}) 
+1
source

Source: https://habr.com/ru/post/1206062/


All Articles