I use the ubuntu 9.04 jaunty jackalope along with other open source C++ libraries.<br>Recently I discovered the<i style="font-family: courier new,monospace;"> fftw-3.2.2</i> libraries, but trying linking it is harder then I thought.<br>



Basically, I have to link these libraries <i style="font-family: courier new,monospace;">-lfftw3 -lm </i>but I do not know how ?<br><br>Here is my CMakeLists.txt:<br><br><font size="1"><span style="font-family: courier new,monospace;">PROJECT (ransac)<br>
<br>cmake_minimum_required(VERSION 2.6)<br><br>FIND_PACKAGE(VTK REQUIRED)<br>IF(NOT VTK_USE_RENDERING)<br>  MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")<br>ENDIF(NOT VTK_USE_RENDERING)<br>
INCLUDE(${VTK_USE_FILE})<br><br>SET(CMAKE_CXX_FLAGS "-Wall -Wno-deprecated")<br>SET(CMAKE_BUILD_TYPE Debug)<br><br>INCLUDE_DIRECTORIES (../common/levmar)<br>LINK_DIRECTORIES (../../common/levmar)<br><br>INCLUDE_DIRECTORIES (~/local/DIR/include)<br>
INCLUDE_DIRECTORIES (../common/ann/include)<br>INCLUDE_DIRECTORIES (../common/ann/lib)<br>LINK_DIRECTORIES (../../common/ann/lib)<br><br>INCLUDE_DIRECTORIES (../common/fftw-3.2.2/.libs)<br>LINK_DIRECTORIES (../../common/fftw-3.2.2/.libs)<br>
<br>ADD_EXECUTABLE (fftw-test fftw-test.cc<br>    ../common/StringTokenizer.cc <br>    ../common/CommonANNRoutines.cc <br>    ../common/CommonVTKRoutines.cc <br>    ../common/CommonIORoutines.cc<br>    ../common/Common3DGeomRoutines.cc<br>
    ../common/CommonTerminalRoutines.cc <br>    ../common/ANN-VTK.cc<br>    ../common/VTKShapes.cc<br>    ../common/CommonPrintRoutines.cc)<br>TARGET_LINK_LIBRARIES (fftw-test vtkCommon vtkRendering vtkWidgets vtkHybrid vtkGraphics ANN lapack levmar)</span></font><br>
<br>The section of code from<i style="font-family: courier new,monospace;"> fftw-test.cc</i> is:<br><br><font size="1"><span style="font-family: courier new,monospace;">  #include "../common/fftw-3.2.2/api/fftw3.h"<br>
  <br>  ...<br>  <br>  // points is an <ANNpointArray> with a number of <header.nr_points> 3D points //<br><br></span></font><font size="1"><span style="font-family: courier new,monospace;">  int p = 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  double *in = (double *) malloc (sizeof(double) * header.nr_points * 3);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  <br>
  // add the the points' coordinates in row major order //<br>  // that means the X values first, then the Y values and at last the Z values //<br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">  for ( int d = 0 ; d < 2; d++ ) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    for ( int idx = 0 ; idx < header.nr_points; idx++ )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      in [p] = points[idx][d];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      p++;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  </span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  int rank = 3;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  fftw_complex *out;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  unsigned flags;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  <br>  // and here is the problem //<br style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;">  fftw_plan forward = fftw_plan_dft_r2c (rank, (const int*) (3 * header.nr_points), in, out, flags);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  </span><span style="font-family: courier new,monospace;">fftw_execute (forward);</span><br style="font-family: courier new,monospace;">
</font><br>Finally my bash output is:<br><br><font size="1"><span style="font-family: courier new,monospace;">goron@lucian:~/work/ransac/build$ make fftw-test</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-- Configuring done</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">-- Generating done</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-- Build files have been written to: /home/goron/work/ransac/build</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">[ 10%] Building CXX object CMakeFiles/fftw-test.dir/fftw-test.cc.o</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[ 20%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/StringTokenizer.cc.o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">[ 30%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/CommonANNRoutines.cc.o</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[ 40%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/CommonVTKRoutines.cc.o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">[ 50%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/CommonIORoutines.cc.o</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[ 60%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/Common3DGeomRoutines.cc.o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">[ 70%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/CommonTerminalRoutines.cc.o</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[ 80%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/ANN-VTK.cc.o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">[ 90%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/VTKShapes.cc.o</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[100%] Building CXX object CMakeFiles/fftw-test.dir/home/goron/work/common/CommonPrintRoutines.cc.o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Linking CXX executable fftw-test</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">CMakeFiles/fftw-test.dir/fftw-test.cc.o: In function `main':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">fftw-test.cc:(.text+0x666): undefined reference to `fftw_plan_dft_r2c'</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">fftw-test.cc:(.text+0x674): undefined reference to `fftw_execute'</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">collect2: ld returned 1 exit status</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">make[3]: *** [fftw-test] Error 1</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">make[2]: *** [CMakeFiles/fftw-test.dir/all] Error 2</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">make[1]: *** [CMakeFiles/fftw-test.dir/rule] Error 2</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">make: *** [fftw-test] Error 2</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">goron@lucian:~/work/ransac/build$</span></font><br>
<br>Has somebody encountered this problem before ? <i style="font-family: courier new,monospace;"><font size="2"><br>


</font></i><span style="font-family: arial,helvetica,sans-serif;"><font size="2"><br>Thank you in advance.</font></span><i style="font-family: courier new,monospace;"><font size="2"><br><br></font></i>