Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake FIND_LIBRARY: link to specified library error

Tags:

ubuntu

cmake

I have already installed the FFTW3 library on my computer and the following files could be found in /usr/lib:

libfftw3f.so.3          libfftw3l_threads.so.3
libfftw3f.so.3.3.0      libfftw3l_threads.so.3.3.0
libfftw3f_threads.so.3      libfftw3.so.3
libfftw3f_threads.so.3.3.0  libfftw3.so.3.3.0
libfftw3l.so.3          libfftw3_threads.so.3
libfftw3l.so.3.3.0      libfftw3_threads.so.3.3.0

I want to install another package that needs to link these libraries, but when I try FIND_LIBRARY(FFTW3_LIBRARIES fftw3) and FIND_LIBRARY(FFTW3_LIBRARIES fftw3f), it just cannot find the libraries.

How can I solve this? Thanks!

Code in CMakeLists.txt:

FIND_PATH(FFTW3_INCLUDE_DIR fftw3.h)
IF(FFLD_HOGPYRAMID_DOUBLE)
  FIND_LIBRARY(FFTW3_LIBRARIES libfftw3.so.3)
ELSE()
  FIND_LIBRARY(FFTW3_LIBRARIES libfftw3f.so.3)
ENDIF()
#IF(NOT FFTW3_INCLUDE_DIR OR NOT FFTW3_LIBRARIES)
IF(NOT FFTW3_INCLUDE_DIR OR NOT FFTW3_LIBRARIES)
  MESSAGE(FATAL_ERROR "Could not find fftw3.")
ENDIF()

error message:

CMake Error at CMakeLists.txt:52 (MESSAGE):
  Could not find fftw3.
like image 664
ethanjyx Avatar asked Mar 08 '13 03:03

ethanjyx


1 Answers

You have the dynamic libraries installed, but do you have the "development" package installed? You probably need a file or symlink named something like:

libfftw3.so

You might need to install an fftw3-devel (or fftw3-dev) package.

Also, try removing the "lib" prefix and the .so.3 suffix:

FIND_LIBRARY(FFTW3_LIBRARIES NAMES fftw3 libfftw3)

If that doesn't work, try adding the PATHS argument:

FIND_LIBRARY(FFTW3_LIBRARIES NAMES fftw3 libfftw3 PATHS /usr/lib <other paths>)

Make sure the CMAKE_FIND_ROOT_PATH variable is set correctly (presumably you're not cross-compiling, so it's likely empty, and cmake will be using sensible locations for finding libraries).

See the cmake man page for detailed usage of the find_library function.

Lastly, look at this site for how to write a find_package script: http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries

like image 81
Patrick Avatar answered Sep 28 '22 06:09

Patrick