title: C++ Armadillo library gives undefined reference to `arma::arma_rng_cxx11_instance'
body: <p>I used CMake to build my project and Catch2 to do the testing. The following is my project structure</p>
  
  <pre><code>├── build
  ├── CMakeLists.txt
  ├── compile_commands.json
  ├── include
  │   ├── node.h
  │   ├── rrt.h
  │   └── tree.h
  ├── Makefile
  ├── package.xml
  ├── scripts
  ├── src
  │   ├── main.cpp
  │   ├── node.cpp
  │   ├── rrt.cpp
  │   └── tree.cpp
  ├── test
  │   ├── CMakeLists.txt
  │   └── test.cpp
  └── third_party
      └── catch.hpp
  </code></pre>
  
  <p>In <code>./CMakeLists.txt</code>:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.3)
  project(rrt_ros)
  
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  set(SOURCES 
      ${CMAKE_CURRENT_SOURCE_DIR}/include/rrt.h
      ${CMAKE_CURRENT_SOURCE_DIR}/include/tree.h
      ${CMAKE_CURRENT_SOURCE_DIR}/include/node.h
      ${CMAKE_CURRENT_SOURCE_DIR}/src/rrt.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/src/tree.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/src/node.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
      )
  
  find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
  find_package(Armadillo REQUIRED)
  FIND_PACKAGE(Eigen3 REQUIRED)
  
  add_executable(
      rrt
      ${SOURCES}
      )
  
  target_include_directories(
      rrt
      PUBLIC
      ${catkin_INCLUDE_DIRS}
      ${EIGEN3_INCLUDE_DIR}
      ${ARMADILLO_INCLUDE_DIR}
      ${CMAKE_CURRENT_SOURCE_DIR}/include
  )
  
  
  target_link_libraries(rrt ${catkin_LIBRARIES} ${ARMADILLO_LIBRARIES})
  add_subdirectory(test)
  </code></pre>
  
  <p>In <code>test/CMakeLists.txt</code>, I have</p>
  
  <pre><code>project(rrt_ros)
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
  find_package(Armadillo REQUIRED)
  FIND_PACKAGE(Eigen3 REQUIRED)
  message("TESTING......" ${CMAKE_CURRENT_SOURCE_DIR}/../include/rrt.h)
  
  add_executable(rrt_test test.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/../include/rrt.h
      ${CMAKE_CURRENT_SOURCE_DIR}/../include/tree.h
      ${CMAKE_CURRENT_SOURCE_DIR}/../include/node.h
      ${CMAKE_CURRENT_SOURCE_DIR}/../src/rrt.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/../src/tree.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/../src/node.cpp
      )
  
  target_include_directories(
      rrt_test
      PUBLIC
      ${catkin_INCLUDE_DIRS}
      ${Armadillo_INCLUDE_DIR}
      ${CMAKE_CURRENT_SOURCE_DIR}/../third_party
      ${CMAKE_CURRENT_SOURCE_DIR}/../include
      )
  
  target_link_libraries(
      rrt_test
      ${catkin_LIBRARIES}
      ${Aramdillo_LIBRARIES}
      )
  </code></pre>
  
  <p>In <code>rrt.cpp</code>, I have a function that calls armadillo's sampling function</p>
  
  <pre><code>arma::randi&lt;arma::mat&gt;(1, 2, arma::distr_params(1, 10))
  </code></pre>
  
  <p>When I compile the project, it gives me an undefined error: </p>
  
  <pre><code>rrt.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x15):  undefined reference to 'arma::arma_rng_cxx11_instance'  
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>However, when I comment out <code>${CMAKE_CURRENT_SOURCE_DIR}/../src/rrt.cpp</code> in <code>./test/CMakeLists.txt</code>, it compiles fine.</p>