title: Error linking boost libraries
body: <p>I want to run code which needs boost libraries. I built it using CMake. Someone else has written this code and cmakelist. It needs to be linked with boost regex, filesystem and system libraries.</p>
  
  <p>I downloaded boost 1.48 and built the above mentioned 3 libraries. Now I have dll and static libraries(.a). I ran a simple program which used these libraries. It worked fine.</p>
  
  <p>Now while using CMake, it gives a linker error relating to the boost libraries. I have checked the cmakelist, but I don't understand what to modify. The relevant part of the cmakelist is:</p>
  
  <pre><code>set(WITH_BOOST_REGEX ON CACHE BOOL "Include BOOST REGEX support")
  set(WITH_BOOST_FILESYSTEM ON CACHE BOOL "Include BOOST FILESYSTEM support")
  set(WITH_BOOST_SYSTEM ON CACHE BOOL "Include BOOST SYSTEM support")
  
  if(WITH_BOOST_REGEX)
    CHECK_MODULE(libboost-regex HAVE_BOOST_REGEX)
  else()
    set(HAVE_BOOST_REGEX FALSE)
  endif()
  
  if(WITH_BOOST_FILESYSTEM)
    CHECK_MODULE(libboost-filesystem HAVE_BOOST_FILESYSTEM)
  else()
    set(HAVE_BOOST_FILESYSTEM FALSE)
  endif()
  </code></pre>
  
  <p>I think that I am just making an error in specifying the path for linking, but I am not able to find how to correct it.</p>
  
  <p>I am successfully running a simple example program linking with both dynamic and static libraries of boost_regex by successfully specifying the path of the object file of that program and libraries.</p>
  
  <p>Now in this code, there are various other modules. It says boost_regex library is missing. link.txt is there which says which libraries to link to, and which is like this:</p>
  
  <pre><code>/usr/bin/c++ CMakeFiles/test_ensembletraining.dir/ensembletraining.o -o ../../bin/test_ensembletraining -rdynamic ../../lib/libensembletraining.so.0.3.2 ../../lib/libutils.so.0.3.2 ../../lib/libfeatureextraction.so.0.3.2 ../../lib/libintegraltransform.so.0.3.2 -lboost_regex.so -lboost_filesystem -lboost_system.so -lopencv_core -lopencv_flann -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_objdetect -lopencv_features2d -lopencv_calib3d -lopencv_legacy -lopencv_contrib -Wl,-rpath,/home/rizwan/vosm-0.3.3/lib:
  </code></pre>
  
  <p>It successfully links with opencv libraries, but not with boost libraries.  I think there is a mistake in specifying the path for link libraries. I tried to find where this path is specified by going through all the cmakelist files.</p>
  
  <p>If anyone wants to help, first download code from VOSM.  Build it using CMake. Download boost 1.48 libraries from the boost website.  If it's working then please tell me how you do that.</p>
  
  <p>This is part of the cmakecachelist:</p>
  
  <pre><code>//Include BOOST FILESYSTEM support
  WITH_BOOST_FILESYSTEM:BOOL=ON
  
  //Include BOOST REGEX support
  WITH_BOOST_REGEX:BOOL=ON
  
  //Include BOOST SYSTEM support
  WITH_BOOST_SYSTEM:BOOL=ON
  
  //Include OPENCV 2.x support
  WITH_OPENCV:BOOL=ON
  </code></pre>
  
  <p>here is cmakelist..</p>
  
  <pre><code>if (BUILD_EXAMPLES)
      project(ensembletraining_exe)
  
      if(CMAKE_COMPILER_IS_GNUCXX)
          set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
      endif()
  
      include_directories(
          "${CMAKE_SOURCE_DIR}/modules/ensembletraining/include"
          "${CMAKE_SOURCE_DIR}/modules/common/include"
          "${CMAKE_SOURCE_DIR}/modules/featureextraction/include"
      )
  
      # ---------------------------------------------
      #      Define executable targets
      # ---------------------------------------------
      MACRO(VO_DEFINE_EXAMPLE name srcs)
          set(the_target "test_${name}")
          add_executable(${the_target} ${srcs})
          set_target_properties(${the_target} PROPERTIES
              OUTPUT_NAME "test_${name}"
              PROJECT_LABEL "(EXAMPLE) test_${name}")
          add_dependencies(${the_target} ensembletraining 
              opencv_core opencv_flann opencv_imgproc opencv_highgui
              opencv_ml opencv_video opencv_objdetect opencv_features2d
              opencv_calib3d opencv_legacy opencv_contrib)
          target_link_libraries(${the_target} ${VOSM_LINKER_LIBS} ensembletraining utils featureextraction integraltransform
              boost_regex boost_filesystem boost_system opencv_core
              opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
              opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
  
          if(WIN32)
              install(TARGETS ${the_target}
                  RUNTIME DESTINATION "tests" COMPONENT main)
          endif()
          install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
      ENDMACRO(VO_DEFINE_EXAMPLE)
  
      file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.c)
  
      foreach(sample_filename ${cpp_samples})
          get_filename_component(sample ${sample_filename} NAME_WE)
          VO_DEFINE_EXAMPLE(${sample}  ${sample_filename})
      endforeach()
  endif(BUILD_EXAMPLES)
  
  if (INSTALL_C_EXAMPLES AND NOT WIN32)
      file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
      install(FILES ${C_SAMPLES}
              DESTINATION share/vosm/tests
              PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
  endif ()
  </code></pre>