title: Linking against boost barfs with 'undefined reference to `boost::system::get_system_category()'
body: <p>I'm having trouble statically linking an app which uses the boost 1.35 libraries. I'm using a linux debian Lenny box, with G++ 4.3.2. Linking without <strong>-static</strong> works without a hitch.</p>
  
  <p>Specifically, </p>
  
  <pre><code>g++ -Wall -Wextra  -pedantic -ggdb3 -O0  -static -l boost_thread-mt -lboost_system-mt -lboost_program_options-mt -lssl -lpthread -l crypto  main.o comandos.o utils.o tunnel.o opciones.o decode.o sysutils.o -o sapp  
  
  main.o: In function `__static_initialization_and_destruction_0':
  /usr/include/boost/system/error_code.hpp:204:undefined reference to `boost::system::get_system_category()'
  /usr/include/boost/system/error_code.hpp:205: undefined reference to `boost::system::get_posix_category()'
  /usr/include/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_posix_category()'
  /usr/include/boost/system/error_code.hpp:210: undefined reference to `boost::system::get_system_category()'
  </code></pre>
  
  <p>I'm linking against boost_system-mt, which is found on my box in /usr/lib. The same thing happens if I link against the non multithread-safe version of boost_system (-lboost_system)</p>
  
  <pre><code>sarraga@saggy:~/sapp/src$ ls -al /usr/lib/libboost_system*a
  -rw-r--r-- 1 root root 23506 2008-05-23 05:32 /usr/lib/libboost_system.a
  lrwxrwxrwx 1 root root    17 2010-08-26 19:10 /usr/lib/libboost_system-gcc42-1_35.a -&gt; libboost_system.a
  lrwxrwxrwx 1 root root    20 2010-08-26 19:10 /usr/lib/libboost_system-gcc42-mt-1_35.a -&gt; libboost_system-mt.a
  -rw-r--r-- 1 root root 23506 2008-05-23 05:32 /usr/lib/libboost_system-mt.a
  </code></pre>
  
  <p>And I find the unresolved symbols there</p>
  
  <pre><code>sarraga@saggy:~/sapp/src$ nm -C /usr/lib/libboost_system-mt.a | grep 'T.*get.*category'
  00000050 T boost::system::get_posix_category()
  000000b0 T boost::system::get_system_category()
  </code></pre>
  
  <p>An strace shows that the linker opens the library</p>
  
  <pre><code> sarraga@saggy:~/sapp/src$ strace -f make 2&gt;&amp;1 | grep boost_system
  [pid 15016] execve("/usr/bin/g++", ["g++", "-Wall", "-Wextra", "-pedantic", "-ggdb3", "-O0", "-static", "-l", "boost_thread-mt", "-lboost_system-mt", "-lboost_program_options-mt", "-lssl", "-lpthread", "-l", "crypto", "main.o", ...], [/* 41 vars */] &lt;unfinished ...&gt;
  ...
  [pid 15018] open("/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libboost_system-mt.a", O_RDONLY|O_LARGEFILE) = 8
  </code></pre>
  
  <p>It's a standard package installation of boost in debian, </p>
  
  <pre><code>sarraga@saggy:~/sapp/src$ dpkg -l | grep boos
  ii  libboost-date-time1.35-dev           1.35.0-5                   set of date-time libraries based on generic programming
  ii  libboost-date-time1.35.0             1.35.0-5                   set of date-time libraries based on generic programming
  ii  libboost-filesystem1.35-dev          1.35.0-5                   filesystem operations (portable paths, iteration over d
  ii  libboost-filesystem1.35.0            1.35.0-5                   filesystem operations (portable paths, iteration over d
  ii  libboost-graph1.35-dev               1.35.0-5                   generic graph components and algorithms in C++
  ii  libboost-graph1.35.0                 1.35.0-5                   generic graph components and algorithms in C++
  ii  libboost-iostreams1.35-dev           1.35.0-5                   Boost.Iostreams Library development files
  ii  libboost-iostreams1.35.0             1.35.0-5                   Boost.Iostreams Library
  ii  libboost-program-options1.35-dev     1.35.0-5                   program options library for C++
  ii  libboost-program-options1.35.0       1.35.0-5                   program options library for C++
  ii  libboost-python1.35-dev              1.35.0-5                   Boost.Python Library development files
  ii  libboost-python1.35.0                1.35.0-5                   Boost.Python Library
  ii  libboost-regex1.35-dev               1.35.0-5                   regular expression library for C++
  ii  libboost-regex1.35.0                 1.35.0-5                   regular expression library for C++
  ii  libboost-serialization1.35-dev       1.35.0-5                   serialization library for C++
  ii  libboost-serialization1.35.0         1.35.0-5                   serialization library for C++
  ii  libboost-signals1.35-dev             1.35.0-5                   managed signals and slots library for C++
  ii  libboost-signals1.35.0               1.35.0-5                   managed signals and slots library for C++
  ii  libboost-system1.35-dev              1.35.0-5                   Operating system (e.g. diagnostics support) library
  ii  libboost-system1.35.0                1.35.0-5                   Operating system (e.g. diagnostics support) library
  ii  libboost-test1.35-dev                1.35.0-5                   components for writing and executing test suites
  ii  libboost-test1.35.0                  1.35.0-5                   components for writing and executing test suites
  ii  libboost-thread1.35-dev              1.35.0-5                   portable C++ multi-threading
  ii  libboost-thread1.35.0                1.35.0-5                   portable C++ multi-threading
  ii  libboost-wave1.35-dev                1.35.0-5                   C99/C++ preprocessor library
  ii  libboost-wave1.35.0                  1.35.0-5                   C99/C++ preprocessor library
  ii  libboost1.35-dev                     1.35.0-5                   Boost C++ Libraries development files
  ii  libboost1.35-doc                     1.35.0-5                   Boost.org libraries documentation
  </code></pre>
  
  <p>I'm sure I'm missing an stupid detail, but I can't find it. Anybody help?</p>