Discussion:
[CMake] Win32: unable to find Curl library with FIND_LIBRARY
Stephen Collyer
2007-11-20 12:20:41 UTC
Permalink
I'm modifying FindCURL.cmake to match my local Win32 installation
of a development tree for Curl, which is installed as follows:

c:\Program Files\curl\libcurl.dll
c:\Program Files\curl\include\curl\curl.h

I've managed to find the include directory by changing the
code as follows:

FIND_PATH(CURL_INCLUDE_DIR NAMES curl/curl.h curl/include/curl/curl.h)

The final path matches the layout and CURL_INCLUDE_DIR is set.
However, I can't get FIND_LIBRARY to find the libcurl.dll file.
The original code was:

FIND_LIBRARY(CURL_LIBRARY NAMES curl)

which failed. I was assuming that it wasn't looking for libcurl
so I changed it to:

FIND_LIBRARY(CURL_LIBRARY NAMES curl libcurl)

which also failed.

I then wondered if it was failing to look in the curl dir
at all so I've currently got:

FIND_LIBRARY(CURL_LIBRARY NAMES curl libcurl PATHS curl
"$ENV{ProgramFiles}/curl)

and that fails too. I'm now pretty much out of ideas. Any
got any suggestions ?

Is it possible to get any verbose o/p from cmake when it runs
these searches ? It would give me some idea of what it was trying
to do behind the scenes.
--
Regards

Steve Collyer
Netspinner Ltd
Andreas Pakulat
2007-11-20 12:40:30 UTC
Permalink
Post by Stephen Collyer
I'm modifying FindCURL.cmake to match my local Win32 installation
c:\Program Files\curl\libcurl.dll
c:\Program Files\curl\include\curl\curl.h
I've managed to find the include directory by changing the
FIND_PATH(CURL_INCLUDE_DIR NAMES curl/curl.h curl/include/curl/curl.h)
The final path matches the layout and CURL_INCLUDE_DIR is set.
However, I can't get FIND_LIBRARY to find the libcurl.dll file.
A .dll is not enough on win32 to use the library. Make sure you also
have either a .def file with the exported symbols or a static import
lib (for MSVC these are called XXX.lib IIRC, for mingw its usuall
.dll.a)

I don't know wether find_library also looks for those, though.

Andreas
--
Today is the first day of the rest of your life.
Pau Garcia i Quiles
2007-11-20 12:49:23 UTC
Permalink
Post by Stephen Collyer
I'm modifying FindCURL.cmake to match my local Win32 installation
c:\Program Files\curl\libcurl.dll
c:\Program Files\curl\include\curl\curl.h
I've managed to find the include directory by changing the
FIND_PATH(CURL_INCLUDE_DIR NAMES curl/curl.h curl/include/curl/curl.h)
The final path matches the layout and CURL_INCLUDE_DIR is set.
However, I can't get FIND_LIBRARY to find the libcurl.dll file.
FIND_LIBRARY(CURL_LIBRARY NAMES curl)
which failed. I was assuming that it wasn't looking for libcurl
FIND_LIBRARY(CURL_LIBRARY NAMES curl libcurl)
which also failed.
I then wondered if it was failing to look in the curl dir
FIND_LIBRARY(CURL_LIBRARY NAMES curl libcurl PATHS curl
"$ENV{ProgramFiles}/curl)
and that fails too. I'm now pretty much out of ideas. Any
got any suggestions ?
Is it possible to get any verbose o/p from cmake when it runs
these searches ? It would give me some idea of what it was trying
to do behind the scenes.
You don't need to modify FindCURL.cmake. Just add c:\Program
Files\curl to CMAKE_LIBRARY_PATH and c:\Program Files\curl\include to
CMAKE_INCLUDE_PATH in your CMakeLists.txt.
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
Stephen Collyer
2007-11-20 13:57:36 UTC
Permalink
You don't need to modify FindCURL.cmake. Just add c:\Program Files\curl
to CMAKE_LIBRARY_PATH and c:\Program Files\curl\include to
CMAKE_INCLUDE_PATH in your CMakeLists.txt.
Thanks to this suggestion and the previous one from Andreas
Pakulat, I have now solved the problem.

It seems that FIND_LIBRARY does indeed look for a .lib file, and
although one was present, it was called libcurl_imp.lib - I hadn't
noticed the _imp before, and renaming it to libcurl.lib, together
with the CMAKE_LIBRARY_PATH change, fixes the problem.
--
Regards

Steve Collyer
Netspinner Ltd
Brandon Van Every
2007-11-20 15:23:02 UTC
Permalink
Post by Stephen Collyer
It seems that FIND_LIBRARY does indeed look for a .lib file, and
although one was present, it was called libcurl_imp.lib - I hadn't
noticed the _imp before, and renaming it to libcurl.lib, together
with the CMAKE_LIBRARY_PATH change, fixes the problem.
You know, looking through that rather large number of unofficial
binary packages for curl on Windows, I have to say their release
process is just goofy. Maybe they'd counter that there isn't one as
far as binaries on Windows go, and they're not responsible for what
individuals do. But it strikes me as being pretty dumb. Maybe you
should get on the curl mailing lists and see if you can wrangle some
consistency out of them.


Cheers,
Brandon Van Every

Loading...