title: undefined reference to `boost::archive::archive_exception::..... appears when building with cmake
body: <p>I have been trying to write a simple program, which simply storage a structure of vector and integer, and read it back later. The code is shown as below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;queue&gt;
  #include &lt;vector&gt;
  
  #include &lt;boost/serialization/vector.hpp&gt;
  #include &lt;boost/archive/text_oarchive.hpp&gt;
  #include &lt;boost/archive/text_iarchive.hpp&gt;
  
  using namespace std;
  struct  testS
  {
      int num1;
      vector&lt;int&gt; num2;
  
      friend class boost::serialization::access;
      template&lt;class Archive&gt;
      void serialize(Archive &amp; ar, const unsigned int version)
      {
          ar &amp; num1;
          ar &amp; num2;
  
      }
  };
  
  int main()
  {
  
      std::queue&lt;std::string&gt; files;
  
      for(int i = 0;i&lt;50;i++){
          testS t1 = testS();
          t1.num1=i;
          for(int k=0;k&lt;10;k++){
              t1.num2.push_back(k);
          }
          std::string fileName = std::to_string(i)+".test";
          std::ofstream tempSaveFile(fileName);
          boost::archive::text_oarchive oa(tempSaveFile);
          oa&lt;&lt;t1;
          files.push(fileName);
      }
  
      for (int i=0;i&lt;50;i++){
          std::string curRecName =files.front();
          std::cout&lt;&lt;"file name: "&lt;&lt;curRecName&lt;&lt;std::endl;
  
          std::ifstream input_file(curRecName);
          testS curRec;
          boost::archive::text_iarchive ia(input_file);
          ia&gt;&gt;curRec;
          for(int k=0;k&lt;10;k++){
              std::cout&lt;&lt;curRec.num2[k];
          }
          std::cout&lt;&lt;'\n';
          std::remove(&amp;curRecName[0]);
          files.pop();
      }
  }
  </code></pre>
  
  <p>However, the above cannot even compile since there is some problem with my CMakeLists.txt</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.0.0)
  project(RecorderTest)
  set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -pthread -lboost_serialization" ) #you can set with add_definitions("-Wall -std=c+11, etc")
  set(Boost_INCLUDE_DIR /home/lowlimb/Downloads/boost_1_70_0)
  set(Boost_LIBRARY_DIR /home/lowlimb/Downloads/boost_1_70_0/stage/lib)
  find_package(Boost 1.70.0 COMPONENTS system filesystem REQUIRED)
  
  include_directories(
      include
      src
      ${Boost_INCLUDE_DIR}
  )
  add_library(
      recLib 
      include/Recorder.hpp
      include/Recorder.cpp
  
  )
  link_directories(${Boost_LIBRARY_DIR})
  
  enable_testing()
  add_executable(rec_o src/main.cpp )
  
  target_link_libraries(rec_o PRIVATE recLib ${Boost_LIBRARIES})
  </code></pre>
  
  <p>The result I get is</p>
  
  <pre><code>CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
    New Boost version may have incorrect or missing dependencies and imported
    targets
  Call Stack (most recent call first):
    /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
    /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
    CMakeLists.txt:6 (find_package)
  
  
  CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
    New Boost version may have incorrect or missing dependencies and imported
    targets
  Call Stack (most recent call first):
    /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
    /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
    CMakeLists.txt:6 (find_package)
  
  
  -- Boost version: 1.70.0
  -- Found the following Boost libraries:
  --   system
  --   filesystem
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/lowlimb/cdrive/UCLA/lab/Exoskeleton/Controller/Test/TestPtr/Final/build
  [ 25%] Building CXX object CMakeFiles/recLib.dir/include/Recorder.cpp.o
  [ 50%] Linking CXX static library librecLib.a
  [ 50%] Built target recLib
  [ 75%] Building CXX object CMakeFiles/rec_o.dir/src/main.cpp.o
  [100%] Linking CXX executable rec_o
  CMakeFiles/rec_o.dir/src/main.cpp.o: In function `boost::archive::text_oarchive::text_oarchive(std::ostream&amp;, unsigned int)':
  main.cpp:(.text._ZN5boost7archive13text_oarchiveC2ERSoj[_ZN5boost7archive13text_oarchiveC5ERSoj]+0x25): undefined reference to `boost::archive::text_oarchive_impl&lt;boost::archive::text_oarchive&gt;::text_oarchive_impl(std::ostream&amp;, unsigned int)'
  CMakeFiles/rec_o.dir/src/main.cpp.o: In function `boost::archive::text_iarchive::text_iarchive(std::istream&amp;, unsigned int)':
  main.cpp:(.text._ZN5boost7archive13text_iarchiveC2ERSij[_ZN5boost7archive13text_iarchiveC5ERSij]+0x25): undefined reference to `boost::archive::text_iarchive_impl&lt;boost::archive::text_iarchive&gt;::text_iarchive_impl(std::istream&amp;, unsigned int)'
  CMakeFiles/rec_o.dir/src/main.cpp.o: In function `boost::archive::text_oarchive_impl&lt;boost::archive::text_oarchive&gt;::~text_oarchive_impl()':
  main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED5Ev]+0x32): undefined reference to `boost::archive::basic_text_oprimitive&lt;std::ostream&gt;::~basic_text_oprimitive()'
  CMakeFiles/rec_o.dir/src/main.cpp.o: In function `boost::archive::text_iarchive_impl&lt;boost::archive::text_iarchive&gt;::~text_iarchive_impl()':
  </code></pre>
  
  <p>This is just part of the output, yet the rest are in similar pattern. I wonder did I made any mistake in CMakeLists.txt? I can assure the paths are 100% correct, no typo there.</p>