Quantcast

Cmake for fftw library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cmake for fftw library

aishwarya selvaraj
Hi all ,
I was writing CMakelist.txt to compile my cpp code(prose ) which makes use of two external libraries :libsndfile and fftw .

The script I have written is below :



CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(PROSE)
########################################################################################################################################################################################################################################################
include(ExternalProject)
MESSAGE(STATUS "Trying to install fftw...")

ExternalProject_Add(fftw
  #GIT_REPOSITORY  https://github.com/FFTW/fftw3
  URL "http://www.fftw.org/fftw-3.3.2.tar.gz"   
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fftw_library
  CONFIGURE_COMMAND ""
    #--Build step-----------------
  BUILD_COMMAND ""
    #--Install step---------------
  UPDATE_COMMAND "" # Skip annoying updates for every build
  INSTALL_COMMAND ""
 )
include_directories(${CMAKE_CURRENT_BINARY_DIR}/fftw_library/src/fftw/api)

########################################################################################################################################################################################################################################################


include(ExternalProject)
MESSAGE(STATUS "Trying to install libsndfile...")

ExternalProject_Add(project_libsndfile
    GIT_REPOSITORY      https://github.com/erikd/libsndfile.git
    PREFIX              lib/libsndfile
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_COMMAND       make
    BUILD_IN_SOURCE     1
    INSTALL_COMMAND     echo Skipping install step for libsndfile
)
ExternalProject_Add_Step(project_libsndfile autogen
   COMMAND              <SOURCE_DIR>/autogen.sh
   DEPENDEES            update
   DEPENDERS            configure
)

ExternalProject_Get_Property(project_libsndfile BINARY_DIR)
SET(libsndfile_lib_dir "${BINARY_DIR}/src/.libs")
SET(libsndfile_inc_dir "${BINARY_DIR}/src")


ADD_LIBRARY(libsndfile STATIC IMPORTED)
SET_PROPERTY(TARGET libsndfile PROPERTY IMPORTED_LOCATION ${libsndfile_lib_dir}/libsndfile.a)

SET(LIBSNDFILE_INCLUDE_PATH "${install_dir}/src/project_libsndfile-build/src/")

INCLUDE_DIRECTORIES(include ${libsndfile_inc_dir})

########################################################################################################################################################################################################################################################

ADD_EXECUTABLE(prose ${PROJECT_SOURCE_DIR}/src/prose.cpp)
TARGET_LINK_LIBRARIES(prose ${fftw} libsndfile )
########################################################################################################################################################################################################################################################


When cmake .. is done building is done without any problem
But when make is one  , I get the following error:


Linking CXX executable prose
CMakeFiles/prose.dir/src/prose.cpp.o: In function `prose(std::vector<double, std::allocator<double> >, int, double)':
prose.cpp:(.text+0x1c86): undefined reference to `fftw_plan_r2r_1d'
prose.cpp:(.text+0x1c9c): undefined reference to `fftw_execute'
prose.cpp:(.text+0x311d): undefined reference to `fftw_plan_r2r_1d'
prose.cpp:(.text+0x3133): undefined reference to `fftw_execute'
collect2: error: ld returned 1 exit status
make[2]: *** [prose] Error 1
make[1]: *** [CMakeFiles/prose.dir/all] Error 2
make: *** [all] Error 2

Where Am I going wrong ?
Can anyone please help me out ?

P.S
`fftw_plan_r2r_1d', `fftw_execute' are functions from fftw library I have used to find dct .


--
Regards,
Aishwarya Selvaraj

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cmake for fftw library

Dan Liew
> Where Am I going wrong ?
> Can anyone please help me out ?

You don't link against fftw which is why you get linking errors. The
`${fftw}` variable is empty.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...