title: How to link C++ program with Boost using CMake
body: <p>What should my CMake file look like for linking my program with the Boost library under Ubuntu?</p>
  
  <p>The errors shown during running <code>make</code>:</p>
  
  <pre><code>main.cpp:(.text+0x3b): undefined reference to `boost::program_options::options_description::m_default_line_length'
  </code></pre>
  
  <p>The main file is really simple:</p>
  
  <pre><code>#include &lt;boost/program_options/options_description.hpp&gt;
  #include &lt;boost/program_options/option.hpp&gt;
  using namespace std;
  #include &lt;iostream&gt;
  
  namespace po = boost::program_options;
  
  int main(int argc, char** argv) {
  
      po::options_description desc("Allowed options");
      desc.add_options()
          ("help", "produce help message")
          ;
  
      return 0;
  }
  </code></pre>
  
  <hr>
  
  <p>I've managed to do that. The only lines that I've added to my CMake files were:</p>
  
  <pre><code>target_link_libraries(
  my_target_file
  ${Boost_PROGRAM_OPTIONS_LIBRARY}
  )
  </code></pre>