[CMake] Find Library would not find the library
Yuri Timenkov
yuri at timenkov.ru
Thu Mar 10 00:17:21 EST 2011
Hi Ankur,
May be you're just missing -devel or -dev pacakges on your system? They
usually provide a symlink from .so to .so.X.Y to allow ld or gcc find the
correct library.
Or do you really have multiple libraries versions installed simultaneously,
each with headers?
On Thu, Mar 10, 2011 at 2:25 AM, Andreas Pakulat <apaku at gmx.de> wrote:
> On 09.03.11 21:36:25, Ankur Handa wrote:
> > I'm using find_library to find a library in a given directory but it has
> > many different versions of this library listed as libcxcore.so,
> > libcxcore.so.2.1 and libcxcore.so.2.1.0 I wrote a very simple cmake file
> >
> > cmake_minimum_required(VERSION 2.8)
> >
> > find_library(OpenCV_LIBRARY_RELEASE NAMES "cxcore" PATHS
> > "/homes/ahanda/openCV2.1/OpenCV-2.1.0/opencvinstall/lib" NO_DEFAULT_PATH)
> >
> > if ( OpenCV_LIBRARY_RELEASE)
> > message("LIBRARY FOUND = " ${OpenCV_LIBRARY_RELEASE})
> > endif()
> >
> > if ( NOT OpenCV_LIBRARY_RELEASE)
> > message("LIBRARY NOT FOUND")
> > endif()
> >
> > It works fine if I search for "cxcore" for which it returns me
> libcxcore.so
> > and the OpenCV_LIBRARY_RELEASE
> > as /homes/ahanda/openCV2.1/OpenCV-2.1.0/opencvinstall/lib/libcxcore.so
> >
> > However if I try to search for cxcore21 or cxcore210 or even
> > libcxcore.so.2.1.0 it won't return me anything and I'd always see LIBRARY
> > NOT FOUND being printed.
> >
> > Could anyone please let me know how to really search for
> libcxcore.so.2.1.0
>
> You can't I think. Thats simply not how cmake or the linker work. The
> linker during the compilation phase will always link against
> lib<name>.so. So you need to make sure that your lib<name>.so is from
> cxcore 2.1.0 and search simply for cxcore.
>
> If you want to make sure that a user has at least cxcore 2.1.0 installed
> you'll need to use other means to find out the version number of the
> installed library. Usually such libs provide a header with version
> numbers which you can read. Or it may have a pkgconfig file for which
> cmake has extra macros to read them. In worst case you could try to grep
> for the version number in the output of strings running over the found
> library.
>
> Andreas
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110310/a76470f1/attachment-0001.htm>
More information about the CMake
mailing list