Reputation: 66935
I want to compile such simple code:
#include <iostream>
#include <fstream>
#include <string>
#include <zlib.h>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main()
{
std::string hello = "Hello world";
std::ofstream zip_png_file( "hello.gz", std::ofstream::binary);
boost::iostreams::filtering_streambuf< boost::iostreams::input> in;
in.push( boost::iostreams::gzip_decompressor());
in.push(hello);
boost::iostreams::copy(in, zip_png_file);
std::cin.get();
return 0;
}
I have compioled Boost with:
-j4 --prefix="C:\Program Files\Boost" --without-mpi --without-python link=static runtime-link=static install
By that time I had no zlib or bzip2 installed in my system. Now I staticly compiled zlib and bzib2 into "C:\Program Files\zlib"
and "C:\Program Files\bzip2"
(with lib
and include
folders in tham)
I created simple VS2010 project and statically linked boost, linked zip added include folders. but instead of compiling I got 5 errors:
Error 5 error C1903: unable to recover from previous error(s); stopping compilation c:\program files (x86)\boost-1.47.0\include\boost\iostreams\traits.hpp 242
Error 1 error C2039: 'category' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' c:\program files (x86)\boost-1.47.0\include\boost\iostreams\traits.hpp
Error 2 error C2146: syntax error : missing ';' before identifier 'type' c:\program files (x86)\boost-1.47.0\include\boost\iostreams\traits.hpp 242
Error 4 error C2208: 'boost::type' : no members defined using this type c:\program files (x86)\boost-1.47.0\include\boost\iostreams\traits.hpp 242
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\boost-1.47.0\include\boost\iostreams\traits.hpp 242
So I wonder can zlib be connected to boost Iostreams after all boost was compiled or I have to rebuild it], if yes what arguments shall I add to mine to get 100% statically linked normal Boost + Boost.Iostreams (with zlib support)?
Upvotes: 0
Views: 1043
Reputation: 47418
First of all, the code would not compile even on a properly configured system: it attempts to use a string (not a stream) as the source, and it attempts to apply gzip_decompressor
to a plain ASCII string.
The following code compiles and runs on Visual Studio 2010 SP1 with boost installed by the BoostPro installer with all default options, no other libraries installed.
#include <fstream>
#include <sstream>
#include <string>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main()
{
std::string hello = "Hello world";
std::istringstream src(hello);
boost::iostreams::filtering_streambuf< boost::iostreams::input> in;
in.push(boost::iostreams::gzip_compressor());
in.push(src);
std::ofstream zip_png_file( "hello.gz", std::ofstream::binary);
boost::iostreams::copy(in, zip_png_file);
}
Upvotes: 3