15

I downloaded "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 environment variable for "CURL_LIBRARY" in Windows to point to the location of the installation of library files for curl, but cmake can't still find it even though 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 the include and lib dirs in Windows Environment Variable, but no change.

EDIT: this is complete project file: cmake project.

Ðаn
  • 10,400
  • 11
  • 57
  • 90
nikk
  • 2,159
  • 3
  • 26
  • 46
  • 1
    May be it requires a specific version and 7.38.0 is to new. Many projects don't accept version that are too new due to potential incompatibilities. Look in the release notes or into the cmake file if you can figure out if it looks for a specific version range. – Oncaphillis Nov 03 '14 at 00:02
  • show your `CMakeLists.txt`, especially part w/ `find_package` – zaufi Nov 03 '14 at 03:00
  • @Oncaphillis: there is not such info about version range. The curl site does not provide downloabable lower versions either. – nikk Nov 03 '14 at 03:35
  • take a look into `FindCURL.cmake` module: it doesn't use any `$ENV`! so, why do you think it should check for your environment? – zaufi Nov 03 '14 at 03:37
  • `FindCURL.cmake` uses "pure" `find_library()` to get a library. so read [documentation](file:///usr/share/doc/cmake/command/find_library.html) and try to give it appropriate hint via "standard" environment variables. – zaufi Nov 03 '14 at 03:41
  • @zaufi I was just looking and trying to run that cmake file (FindCURL.cmake). I found after several hours of trying to solve this problem. It looks like its written for linux (I use Windows). I tried to modify it by chaning to the path /usr/lib to C:/curl/lib but still didnt work. I am new to cmake too. Maybe I am missing something. – nikk Nov 03 '14 at 03:43
  • yes, you definitely need to read some (more) tutorials. you definitely shouldn't modify `FindCURL.cmake` and no, you don't need to run it! read manual about `find_package()` for further details. then look into `FindCURL.cmake` and read the manual for every call you don't familiar with… – zaufi Nov 03 '14 at 04:52
  • Did you restart your computer after setting the PATH variable? – Aralox Nov 03 '14 at 05:17
  • @Aralox actually thats a good point! One article suggested that I do. and I just not long ago. I still have the the error about paths. – nikk Nov 03 '14 at 06:24
  • All: I just added the complete cmake project above, unmodified. – nikk Nov 03 '14 at 06:31

3 Answers3

24

I faced same problem and this SO question was one of top during my search. So I am giving solution that I found. Following cmake worked for me to use libcurl include in my code. Hope it will be usefull for 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})
miradham
  • 1,956
  • 11
  • 25
1

via pkgconfig

include(FindPkgConfig)
pkg_check_modules(CURL libcurl REQUIRED)
include_directories(
  SYSTEM ${CURL_INCLUDE_DIRS}
)
target_link_libraries(YOURTARGETNAME
  ${CURL_LIBRARIES}
)
giuspen
  • 1,215
  • 3
  • 18
  • 30
0

You should install the libcurl-dev pkg with the following cmd first:

$ yum search libcurl

Loading mirror speeds from cached hostfile
============================= N/S Matched: libcurl =============================
libcurl-devel.i686 : Files needed for building applications with libcurl
libcurl-devel.x86_64 : Files needed for building applications with libcurl
curlftpfs.x86_64 : CurlFtpFS is a filesystem for accessing FTP hosts based on
                 : FUSE and libcurl
curlpp.i686 : A C++ wrapper for libcURL
curlpp.x86_64 : A C++ wrapper for libcURL
libcurl.i686 : A library for getting files from web servers
libcurl.x86_64 : A library for getting files from web servers
perl-WWW-Curl.x86_64 : Perl extension interface for libcurl
python-pycurl.x86_64 : A Python interface to libcurl
rubygem-curb.x86_64 : Ruby libcurl bindings

then install the available pkg

sudu yum install libcurl-devel.x86_64