It was the question of binary files.
Thank You for Your help.

Message: 5
Date: Mon, 19 Mar 2012 10:57:29 -0400
From: "Andrew Holden" <aholden@charteroaksystems.com>
To: <boost-users@lists.boost.org>
Subject: Re: [Boost-users] boost.zlib on Windows
Message-ID:
      <1D97E025367AFB4A8C528590A3715BF4425F20@archerysummit2.willamette.charteroaksystems.com>

Content-Type: text/plain;       charset="iso-8859-1"

On Sunday, March 18, 2012 10:05 AM, L?szl? Mar?k wrote:
>
> I would like to ask You what is the status of Boost.zlib on
> Windows. I have a program that uses Boost.iostreams to create
> a gzip file. It compiles both on Windows and Linux and on
> Linux it creates a functional gz file. On Windows it creates
> a gz file but when I try to decompress the file it gives me
> "data error".
>
> When I look at Boost's regression tests both gzip and zlib is
> missing on Windows. Has anybody successfully run Boost.zlib
> on Windows recently? Is there some flush method that should
> be called, but on Linux it does not show any symptoms?

I agree with Artyom Beilis.  It sounds like you're opening the files in text mode.  This causes Windows to insert a carriage return (0x0D) before each line feed (0x0A), but has no effect on Linux or other Unix-like operating systems.

Here is the actual code I use to open a gz or bz2 file for writing in one of my projects, which produced valid gz files with boost 1.48 (untested with 1.49) and Visual Studio 2010, both in i386 and AMD64 modes.  Ignore the references to tbb::scalable_allocator.  In particular, note the last line where I specify the file_sink should be binary:

boost::iostreams::filtering_stream <boost::iostreams::output, char,
std::char_traits <char>, tbb::scalable_allocator <char>> output_file;

if (boost::iends_with (file_name, ".gz"))
      output_file.push (boost::iostreams::basic_gzip_compressor <tbb::scalable_allocator <char>> (boost::iostreams::zlib::best_compression));

else if (boost::iends_with (file_name, ".bz2"))
      output_file.push (boost::iostreams::basic_bzip2_compressor <tbb::scalable_allocator <char>> ());

output_file.push (boost::iostreams::file_sink (file_name.c_str(), std::ios::out | std::ios::binary));