title: c++ What files and libs to include?
body: <p>Many times I find useful code examples on the Internet. About half of the time they don't specify what files to include or even what libs to include on the command line with -l. How do you usually find that out?</p>
  
  <p>edit note: The problem below has been solved. The remainder of this post can be skipped.</p>
  
  <p>Right now, I'm getting tons of errors while trying to compile:</p>
  
  <pre><code>53: string Gunzip::gunzip(string&amp; compressed)
  54: {
  55:   namespace io = boost::iostreams;
  56:
  57:   io::filtering_istream gunzip;
  58:   gunzip.push(io::gzip_decompressor());
  59:   std::istringstream in_stream = std::istringstream(compressed);
  60:   gunzip.push(in_stream);
  61:
  62:   stringstream strstream;
  63:   io::copy(gunzip, strstream);
  64:   return strstream.str();
  65: }
  </code></pre>
  
  <p>After a day on the Internet I'm trying:</p>
  
  <pre><code>option: 3 -L/usr/include/boost
  and:
   8: #include &lt;string&gt;
   9: #include &lt;iostream&gt;
  10: #include &lt;sstream&gt;
  
  15: #include &lt;boost/iostreams/copy.hpp&gt;
  16: #include &lt;boost/iostreams/device/array.hpp&gt;
  17: #include &lt;boost/iostreams/device/back_inserter.hpp&gt;
  18: #include &lt;boost/iostreams/filter/gzip.hpp&gt;
  19: #include &lt;boost/iostreams/filter/test.hpp&gt;
  20: #include &lt;boost/iostreams/filtering_stream.hpp&gt;
  </code></pre>
  
  <p>The error I have is:</p>
  
  <pre><code>                 from /usr/include/c++/4.5/string:45,
                   from Gunzip.cpp:8:
  /usr/include/c++/4.5/bits/ios_base.h: In copy constructor     ‘std::basic_ios&lt;char&gt;::basic_ios(const std::basic_ios&lt;char&gt;&amp;)’:
  In file included from /usr/include/c++/4.5/bits/localefwd.h:43:0,
  /usr/include/c++/4.5/bits/ios_base.h:785:5: error: ‘std::ios_base::ios_base(const     std::ios_base&amp;)’ is private
  /usr/include/c++/4.5/iosfwd:77:11: error: within this context
  /usr/include/c++/4.5/iosfwd: In copy constructor     ‘std::basic_istringstream&lt;char&gt;::basic_istringstream(const     std::basic_istringstream&lt;char&gt;&amp;)’:
  /usr/include/c++/4.5/iosfwd:97:11: note: synthesized method     ‘std::basic_ios&lt;char&gt;::basic_ios(const std::basic_ios&lt;char&gt;&amp;)’ first required here 
  /usr/include/c++/4.5/streambuf: In copy constructor     ‘std::basic_stringbuf&lt;char&gt;::basic_stringbuf(const std::basic_stringbuf&lt;char&gt;&amp;)’:
  /usr/include/c++/4.5/streambuf:773:7: error: ‘std::basic_streambuf&lt;_CharT,     _Traits&gt;::basic_streambuf(const std::basic_streambuf&lt;_CharT, _Traits&gt;::__streambuf_type&amp;)     [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, std::basic_streambuf&lt;_CharT,     _Traits&gt;::__streambuf_type = std::basic_streambuf&lt;char&gt;]’ is private
  /usr/include/c++/4.5/iosfwd:93:11: error: within this context
  /usr/include/c++/4.5/iosfwd: In copy constructor     ‘std::basic_istringstream&lt;char&gt;::basic_istringstream(const     std::basic_istringstream&lt;char&gt;&amp;)’:
  /usr/include/c++/4.5/iosfwd:97:11: note: synthesized method     ‘std::basic_stringbuf&lt;char&gt;::basic_stringbuf(const std::basic_stringbuf&lt;char&gt;&amp;)’ first     required here 
  Gunzip.cpp: In member function ‘std::string Gunzip::gunzip(std::string&amp;)’:
  Gunzip.cpp:59:65: note: synthesized method     ‘std::basic_istringstream&lt;char&gt;::basic_istringstream(const std::basic_istringstream&lt;char&gt;&amp;)’ first required here 
  make[2]: Leaving directory `/home/albert/NetBeansProjects/Arb3'
  make[1]: Leaving directory `/home/albert/NetBeansProjects/Arb3'
  make[2]: *** [build/Debug/GNU-Linux-x86/Gunzip.o] Error 1
  make[1]: *** [.build-conf] Error 2
  make: *** [.build-impl] Error 2
  
  BUILD FAILED (exit value 2, total time: 9s)
  </code></pre>
  
  <p>I can remove the first 3 includes to obtain other errors I don't understand. I don't know which errors are better.</p>
  
  <ol>
  <li>Is this error related to includes? How should I know? I'm blaming the includes because so far all errors were due to includes. I don't know what basic_ios is.</li>
  <li>How do you find out what to include and what libs to use?</li>
  </ol>