title: Undefined reference to "function name from external library"
body: <p>I'm using Ubuntu 12 64 bit, installed fftw library version 2.1.5.
  I have a c++ project with use CMake to build the make file. This is my cmakelist.text:</p>
  
  <pre><code>project(MP)
  cmake_minimum_required(VERSION 2.8)
  
  if(TYPE STREQUAL "Debug")
          set(CMAKE_BUILD_TYPE "Debug")
  else()
          set(CMAKE_BUILD_TYPE "Release")
  endif()
  
  
  if(CMAKE_COMPILER_IS_GNUCXX)
      add_definitions( -std=c++11 )
  endif()
  
  
  find_package(GLUT REQUIRED)
  find_package(OpenGL REQUIRED)
  
  find_library(GLUI libglui.a ./vendor/lib)
  
  
  include_directories(${OPENGL_INCLUDE_DIR}
                     ./vendor/include)
  
  LINK_DIRECTORIES(/usr/local/lib)
  LINK_DIRECTORIES(/usr/lib)
  LINK_DIRECTORIES(/usr/bin)
  
  aux_source_directory(. SRC_LIST)
  add_executable(${PROJECT_NAME} ${SRC_LIST})
  
  target_link_libraries(${PROJECT_NAME} GL GLU glut ${GLUI})
  </code></pre>
  
  <p>When I tried running the make file create by Cmake, i got this problem:
  CMakeFiles/SciVis.dir/Simulation.cc.o: In function `Simulation::init_simulation(unsigned long)':</p>
  
  <pre><code>Simulation.cc:(.text+0x2d5): undefined reference to `rfftw2d_create_plan'
  Simulation.cc:(.text+0x2ee): undefined reference to `rfftw2d_create_plan'
  CMakeFiles/SciVis.dir/Simulation.cc.o: In function `Simulation::solve()':
  Simulation.cc:(.text+0x881): undefined reference to `rfftwnd_one_real_to_complex'
  Simulation.cc:(.text+0x891): undefined reference to `rfftwnd_one_real_to_complex'
  Simulation.cc:(.text+0xa7f): undefined reference to `rfftwnd_one_complex_to_real'
  Simulation.cc:(.text+0xa8f): undefined reference to `rfftwnd_one_complex_to_real'
  CMakeFiles/SciVis.dir/Simulation.cc.o: In function `Simulation::FFT(int, void*)':
  Simulation.cc:(.text+0x390): undefined reference to `rfftwnd_one_complex_to_real'
  Simulation.cc:(.text+0x3a0): undefined reference to `rfftwnd_one_real_to_complex'
  collect2: error: ld returned 1 exit status
  make[2]: *** [SciVis] Error 1
  make[1]: *** [CMakeFiles/SciVis.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>In my Simulation.cc file:</p>
  
  <pre><code>#include &lt;fftw.h&gt;
  void Simulation::init_simulation(size_t n)
  {
      //Allocate data structures
      size_t dim     = n * 2 * (n / 2 + 1);
      vx       = new fftw_real[dim];
      vy       = new fftw_real[dim];
      vx0      = new fftw_real[dim];
      vy0      = new fftw_real[dim];
  
      fx      = new fftw_real[n * n];
      fy      = new fftw_real[n * n];
      rho     = new fftw_real[n * n];
      rho0    = new fftw_real[n * n];
  
      plan_rc = rfftw2d_create_plan(n, n, FFTW_REAL_TO_COMPLEX, FFTW_IN_PLACE);
      plan_cr = rfftw2d_create_plan(n, n, FFTW_COMPLEX_TO_REAL, FFTW_IN_PLACE);
  
      // Initialize data structures to 0
      for (size_t i = 0; i &lt; n * n; i++)
      { 
          vx[i] = vy[i] = vx0[i] = vy0[i] = fx[i] = fy[i] = rho[i] = rho0[i] = 0.0f; 
      }
  }
  
  void Simulation::FFT(int direction,void* vx)
  {
      if(direction==1) rfftwnd_one_real_to_complex(plan_rc,(fftw_real*)vx,(fftw_complex*)vx);
      else             rfftwnd_one_complex_to_real(plan_cr,(fftw_complex*)vx,(fftw_real*)vx);
  }
  </code></pre>
  
  <p>I dont know where I were wrong, can someone please help me ?
  <br>Thank you very much.</p>