title: C++ / Boost: Undefined Symbols in example?
body: <p>The example I'm trying to compile is from: <a href="http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/examples.html" rel="noreferrer">http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/examples.html</a>
  (the chat example)</p>
  
  <p>Here is what I'm using to make it:</p>
  
  <pre><code>&gt;&gt;&gt;    g++ chat_client.cpp chat_message.hpp
  &gt;&gt;&gt;    g++ chat_server.cpp chat_message.hpp
  </code></pre>
  
  <p>This is what the terminal outputs:</p>
  
  <pre><code>% g++ chat_client.cpp chat_message.hpp
  In file included from chat_client.cpp:17:
  chat_message.hpp: In member function ‘void chat_message::encode_header()’:
  chat_message.hpp:84: warning: format ‘%4d’ expects type ‘int’, but argument 3 has type ‘size_t’
  ld: warning: in chat_message.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
  Undefined symbols:
    "boost::system::generic_category()", referenced from:
        __static_initialization_and_destruction_0(int, int)in cctJA2c1.o
        __static_initialization_and_destruction_0(int, int)in cctJA2c1.o
    "boost::thread::start_thread()", referenced from:
        boost::thread::thread&lt;boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt; &gt;(boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt;, boost::disable_if&lt;boost::is_convertible&lt;boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt;&amp;, boost::detail::thread_move_t&lt;boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt; &gt; &gt;, boost::thread::dummy*&gt;::type)in cctJA2c1.o
    "boost::thread::join()", referenced from:
        _main in cctJA2c1.o
    "typeinfo for boost::detail::thread_data_base", referenced from:
        typeinfo for boost::detail::thread_data&lt;boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt; &gt;in cctJA2c1.o
    "vtable for boost::detail::thread_data_base", referenced from:
        boost::detail::thread_data_base::thread_data_base()in cctJA2c1.o
    "boost::thread::~thread()", referenced from:
        _main in cctJA2c1.o
        _main in cctJA2c1.o
    "boost::detail::thread_data_base::~thread_data_base()", referenced from:
        boost::detail::thread_data&lt;boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt; &gt;::~thread_data()in cctJA2c1.o
        boost::detail::thread_data&lt;boost::_bi::bind_t&lt;unsigned long, boost::_mfi::mf0&lt;unsigned long, boost::asio::io_service&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;boost::asio::io_service*&gt; &gt; &gt; &gt;::~thread_data()in cctJA2c1.o
    "boost::system::system_category()", referenced from:
        boost::system::get_system_category()     in cctJA2c1.o
        boost::system::error_code::error_code()in cctJA2c1.o
        __static_initialization_and_destruction_0(int, int)in cctJA2c1.o
  ld: symbol(s) not found
  collect2: ld returned 1 exit status
  </code></pre>
  
  <ul>
  <li>Boost is installed correctly. I have another app that uses a couple of boosts bit features.</li>
  </ul>
  
  <p>UPDATE:
  this is the current command I'm using: </p>
  
  <pre><code>% g++ chat_client.cpp chat_message.hpp -lboost_asio -lboost_thread -o client -L/opt/local/lib/
  </code></pre>
  
  <p>says it can't find -lboost_asio</p>
  
  <p>I looked in opt/local/lib (where boost is installed) and I don't see any libboost_asio.so or anything like that =\</p>