title: Unable to link against boost libraries
body: <p>I can't get my g++ to compile and link a minimal boost co-routine program (and I guess other components as well) on my machine.</p>
  
  <pre><code>// example.cpp
  
  #include &lt;boost/coroutine/all.hpp&gt;
  #include &lt;iostream&gt;
  using namespace boost::coroutines;
  
  void mycorofunc(coroutine&lt;void&gt;::push_type &amp;sink){
    std::cout &lt;&lt; "1";
    sink();
    std::cout &lt;&lt; " 3";
  }
  
  int main() {
    coroutine&lt;void&gt;::pull_type source{mycorofunc};
    std::cout &lt;&lt; " 2";
    source();
    std::cout &lt;&lt; " 4!" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I used apt-get to install boost (libboost-all-dev), but neither </p>
  
  <pre><code>g++ example.cpp -lboost_coroutine -lboost_system
  </code></pre>
  
  <p>nor</p>
  
  <pre><code>g++ example.cpp -I/usr/include -L/usr/lib/x86_64-linux-gnu -lboost_coroutine -lboost_system
  </code></pre>
  
  <p>works. g++'s output is as follows:</p>
  
  <pre><code>In file included from /usr/include/boost/coroutine/v1/coroutine.hpp:19:0,
                   from /usr/include/boost/coroutine/coroutine.hpp:13,
                   from /usr/include/boost/coroutine/all.hpp:11,
                   from example.cpp:3:
  /usr/include/boost/type_traits/function_traits.hpp: In instantiation of ‘struct boost::function_traits&lt;void&gt;’:
  example.cpp:7:31:   required from here
  /usr/include/boost/type_traits/function_traits.hpp:168:8: error: invalid use of incomplete type ‘struct boost::detail::function_traits_helper&lt;void*&gt;’
   struct function_traits : 
          ^
  /usr/include/boost/type_traits/function_traits.hpp:21:36: error: declaration of ‘struct boost::detail::function_traits_helper&lt;void*&gt;’
   template&lt;typename Function&gt; struct function_traits_helper;
                                      ^
  example.cpp:7:31: error: ‘arity’ is not a member of ‘boost::function_traits&lt;void&gt;’
   void mycorofunc(coroutine&lt;void&gt;::push_type &amp;sink){
                                 ^
  example.cpp:7:31: error: template argument 2 is invalid
  example.cpp:7:44: error: expected ‘,’ or ‘...’ before ‘&amp;’ token
   void mycorofunc(coroutine&lt;void&gt;::push_type &amp;sink){
                                              ^
  example.cpp: In function ‘void mycorofunc(int)’:
  example.cpp:9:8: error: ‘sink’ was not declared in this scope
     sink();
          ^
  example.cpp: In function ‘int main()’:
  example.cpp:14:17: error: ‘arity’ is not a member of ‘boost::function_traits&lt;void&gt;’
     coroutine&lt;void&gt;::pull_type source{mycorofunc};
                   ^
  example.cpp:14:17: error: template argument 2 is invalid
  example.cpp:14:30: error: expected initializer before ‘source’
     coroutine&lt;void&gt;::pull_type source{mycorofunc};
                                ^
  example.cpp:16:10: error: ‘source’ was not declared in this scope
     source();
  </code></pre>
  
  <p>Some more information about my environment:</p>
  
  <pre><code>$$ locate coroutine/all.hpp
  /usr/include/boost/coroutine/all.hpp
  /usr/local/boost_1_58_0/boost/coroutine/all.hpp
  
  $$ locate boost_system
  /usr/lib/x86_64-linux-gnu/libboost_system.a
  /usr/lib/x86_64-linux-gnu/libboost_system.so
  /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0
  
  $$ locate boost_coroutine
  /usr/lib/x86_64-linux-gnu/libboost_coroutine.a
  
  $$ g++ -E -x c++ - -v &lt; /dev/null  # printing g++ include path 
  Using built-in specs.
  COLLECT_GCC=g++
  Target: x86_64-linux-gnu
  Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
  Thread model: posix
  gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 
  COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
   /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=x86-64 -fstack-protector -Wformat -Wformat-security
  ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
  ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
  ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
  #include "..." search starts here:
  #include &lt;...&gt; search starts here:
   /usr/include/c++/4.8
   /usr/include/x86_64-linux-gnu/c++/4.8
   /usr/include/c++/4.8/backward
   /usr/lib/gcc/x86_64-linux-gnu/4.8/include
   /usr/local/include
   /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
   /usr/include/x86_64-linux-gnu
   /usr/include
  End of search list.
  # 1 "&lt;stdin&gt;"
  # 1 "&lt;command-line&gt;"
  # 1 "/usr/include/stdc-predef.h" 1 3 4
  # 1 "&lt;command-line&gt;" 2
  # 1 "&lt;stdin&gt;"
  COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
  LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
  COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
  </code></pre>
  
  <p>Compiler: have tried both g++ (v. 4.8.2) and g++-5</p>
  
  <p>Distro: Ubuntu 14.04.1 LTS</p>