|
Boost Users : |
Subject: Re: [Boost-users] help needed with bzip2/zlib with boost
From: Sebastian Korf (teddy-sk_at_[hidden])
Date: 2009-09-11 12:25:32
Hi,
i had the very same problems yesterday (but i use the gcc compiler).
You have to build the iostream library new:
http://www.boost.org/doc/libs/1_39_0/libs/iostreams/doc/index.html
To do that you have to get to boost/libs/iostream/build in a cmd and
launch bjam with following settings:
bjam "-sNO_COMPRESSION=0" "-sNO_ZLIB=0" "-sZLIB_SOURCE=C:\Dev\zlib"
if you want to use bzip2 just define the variables for bzip2.
Of course you need the files from bzip2 and zlib.
If you have recompiled iostreams you get 2 dlls one for iostreams AND
one for bzip2 or zlib link it with your programm (boost_iostreams AND
bzip2 /zlib).
I hope it helps you,
SK
ChristinaDRS schrieb:
> Hello,
>
> I am trying to get the code below to compile in Visual Studios without luck.
> I downloaded and built the seperate zlib and bzip2 libraries and renamed
> them to:
>
> libboost_zlib-vc90-mt-gd-1_39.lib
> libboost_bzip2-vc90-mt-gd-1_39.lib
>
> because I was getting linking errors that I was missing thes elibs. but I
> get a bunch of unresolved linking errors now.. any idea what I might be
> doing wrong?
>
> I am guessing they must be needed to be built actually by boost? Is there
> any instructions on how to do this?
>
> Thanks!!!
>
>
> 1>------ Build started: Project: BoostCompression, Configuration: Debug
> Win32 ------
> 1>Linking...
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::default_compression"
> (?default_compression_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::deflated" (?deflated_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::default_strategy"
> (?default_strategy_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2019: unresolved external symbol "int __cdecl
> test_main(int,char * * const)" (?test_main@@YAHHQAPAD_at_Z) referenced in
> function "public: int __thiscall
> boost::minimal_test::caller::operator()(void)"
> (??Rcaller_at_minimal_test_at_boost@@QAEHXZ)
> 1>main.obj : error LNK2019: unresolved external symbol "protected:
> __thiscall boost::iostreams::detail::bzip2_base::~bzip2_base(void)"
> (??1bzip2_base_at_detail@iostreams_at_boost@@IAE_at_XZ) referenced in function
> "public: __thiscall boost::iostreams::detail::bzip2_compressor_impl<class
> std::allocator<char> >::~bzip2_compressor_impl<class std::allocator<char>
>
>> (void)"
>>
> (??1?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_at_XZ)
> 1>main.obj : error LNK2019: unresolved external symbol "protected:
> __thiscall boost::iostreams::detail::zlib_base::~zlib_base(void)"
> (??1zlib_base_at_detail@iostreams_at_boost@@IAE_at_XZ) referenced in function
> __unwindfunclet$??0?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_at_ABUzlib_params_at_23@@Z$0
> 1>main.obj : error LNK2019: unresolved external symbol "protected:
> __thiscall boost::iostreams::detail::zlib_base::zlib_base(void)"
> (??0zlib_base_at_detail@iostreams_at_boost@@IAE_at_XZ) referenced in function
> "public: __thiscall boost::iostreams::detail::zlib_compressor_impl<class
> std::allocator<char> >::zlib_compressor_impl<class std::allocator<char>
>
>> (struct boost::iostreams::zlib_params const &)"
>>
> (??0?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_at_ABUzlib_params_at_23@@Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: void
> __thiscall boost::iostreams::detail::zlib_base::reset(bool,bool)"
> (?reset_at_zlib_base_at_detail@iostreams_at_boost@@IAEX_N0_at_Z) referenced in function
> "public: __thiscall boost::iostreams::detail::zlib_compressor_impl<class
> std::allocator<char> >::~zlib_compressor_impl<class std::allocator<char>
>
>> (void)"
>>
> (??1?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_at_XZ)
> 1>main.obj : error LNK2019: unresolved external symbol "protected:
> __thiscall boost::iostreams::detail::bzip2_base::bzip2_base(struct
> boost::iostreams::bzip2_params const &)"
> (??0bzip2_base_at_detail@iostreams_at_boost@@IAE_at_ABUbzip2_params_at_23@@Z) referenced
> in function "public: __thiscall
> boost::iostreams::detail::bzip2_compressor_impl<class std::allocator<char>
>
>> ::bzip2_compressor_impl<class std::allocator<char> >(struct
>>
> boost::iostreams::bzip2_params const &)"
> (??0?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_at_ABUbzip2_params_at_23@@Z)
> 1>main.obj : error LNK2019: unresolved external symbol "private: void
> __thiscall boost::iostreams::detail::zlib_base::do_init(struct
> boost::iostreams::zlib_params const &,bool,void * (__cdecl*)(void *,unsigned
> int,unsigned int),void (__cdecl*)(void *,void *),void *)"
> (?do_init_at_zlib_base_at_detail@iostreams_at_boost@@AAEXABUzlib_params_at_34@_NP6APAXPAXII_at_ZP6AX22@Z2_at_Z)
> referenced in function "protected: void __thiscall
> boost::iostreams::detail::zlib_base::init<class std::allocator<char>
>
>> (struct boost::iostreams::zlib_params const &,bool,struct
>>
> boost::iostreams::detail::zlib_allocator<class std::allocator<char>,class
> std::allocator<char> > &)"
> (??$init_at_V?$allocator_at_D@std@@@zlib_base_at_detail@iostreams_at_boost@@IAEXABUzlib_params_at_23@_NAAU?$zlib_allocator_at_V?$allocator_at_D@std@@V12@@123@@Z)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::stream_end" (?stream_end_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2019: unresolved external symbol "public: static void
> __cdecl boost::iostreams::zlib_error::check(int)"
> (?check_at_zlib_error_at_iostreams@boost@@SAXH_at_Z) referenced in function "public:
> bool __thiscall boost::iostreams::detail::zlib_compressor_impl<class
> std::allocator<char> >::filter(char const * &,char const *,char * &,char
> *,bool)"
> (?filter@?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: void
> __thiscall boost::iostreams::detail::zlib_base::after(char const * &,char *
> &,bool)" (?after_at_zlib_base_at_detail@iostreams_at_boost@@IAEXAAPBDAAPAD_N_at_Z)
> referenced in function "public: bool __thiscall
> boost::iostreams::detail::zlib_compressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: int
> __thiscall boost::iostreams::detail::zlib_base::deflate(int)"
> (?deflate_at_zlib_base_at_detail@iostreams_at_boost@@IAEHH_at_Z) referenced in function
> "public: bool __thiscall
> boost::iostreams::detail::zlib_compressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::no_flush" (?no_flush_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::finish" (?finish_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: void
> __thiscall boost::iostreams::detail::zlib_base::before(char const * &,char
> const *,char * &,char *)"
> (?before_at_zlib_base_at_detail@iostreams_at_boost@@IAEXAAPBDPBDAAPADPAD_at_Z)
> referenced in function "public: bool __thiscall
> boost::iostreams::detail::zlib_compressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$zlib_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::bzip2::stream_end"
> (?stream_end_at_bzip2@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2019: unresolved external symbol "public: static void
> __cdecl boost::iostreams::bzip2_error::check(int)"
> (?check_at_bzip2_error_at_iostreams@boost@@SAXH_at_Z) referenced in function "public:
> bool __thiscall boost::iostreams::detail::bzip2_compressor_impl<class
> std::allocator<char> >::filter(char const * &,char const *,char * &,char
> *,bool)"
> (?filter@?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: void
> __thiscall boost::iostreams::detail::bzip2_base::after(char const * &,char *
> &)" (?after_at_bzip2_base_at_detail@iostreams_at_boost@@IAEXAAPBDAAPAD_at_Z) referenced
> in function "public: bool __thiscall
> boost::iostreams::detail::bzip2_compressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: int
> __thiscall boost::iostreams::detail::bzip2_base::compress(int)"
> (?compress_at_bzip2_base_at_detail@iostreams_at_boost@@IAEHH_at_Z) referenced in
> function "public: bool __thiscall
> boost::iostreams::detail::bzip2_compressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::bzip2::run" (?run_at_bzip2@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::bzip2::finish" (?finish_at_bzip2@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: void
> __thiscall boost::iostreams::detail::bzip2_base::before(char const * &,char
> const *,char * &,char *)"
> (?before_at_bzip2_base_at_detail@iostreams_at_boost@@IAEXAAPBDPBDAAPADPAD_at_Z)
> referenced in function "public: bool __thiscall
> boost::iostreams::detail::bzip2_compressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: int
> __thiscall boost::iostreams::detail::zlib_base::inflate(int)"
> (?inflate_at_zlib_base_at_detail@iostreams_at_boost@@IAEHH_at_Z) referenced in function
> "public: bool __thiscall
> boost::iostreams::detail::zlib_decompressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$zlib_decompressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2001: unresolved external symbol "int const
> boost::iostreams::zlib::sync_flush" (?sync_flush_at_zlib@iostreams_at_boost@@3HB)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: int
> __thiscall boost::iostreams::detail::bzip2_base::decompress(void)"
> (?decompress_at_bzip2_base_at_detail@iostreams_at_boost@@IAEHXZ) referenced in
> function "public: bool __thiscall
> boost::iostreams::detail::bzip2_decompressor_impl<class std::allocator<char>
>
>> ::filter(char const * &,char const *,char * &,char *,bool)"
>>
> (?filter@?$bzip2_decompressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N_at_Z)
> 1>main.obj : error LNK2019: unresolved external symbol "protected: void
> __thiscall boost::iostreams::detail::bzip2_base::end(bool)"
> (?end_at_bzip2_base_at_detail@iostreams_at_boost@@IAEX_N_at_Z) referenced in function
> "public: void __thiscall
> boost::iostreams::detail::bzip2_compressor_impl<class std::allocator<char>
>
>> ::close(void)"
>>
> (?close@?$bzip2_compressor_impl_at_V?$allocator_at_D@std@@@detail_at_iostreams@boost@@QAEXXZ)
> 1>main.obj : error LNK2019: unresolved external symbol "private: void
> __thiscall boost::iostreams::detail::bzip2_base::do_init(bool,void *
> (__cdecl*)(void *,int,int),void (__cdecl*)(void *,void *),void *)"
> (?do_init_at_bzip2_base_at_detail@iostreams_at_boost@@AAEX_NP6APAXPAXHH_at_ZP6AX11@Z1_at_Z)
> referenced in function "protected: void __thiscall
> boost::iostreams::detail::bzip2_base::init<class std::allocator<char>
>
>> (bool,struct boost::iostreams::detail::bzip2_allocator<class
>>
> std::allocator<char>,class std::allocator<char> > &)"
> (??$init_at_V?$allocator_at_D@std@@@bzip2_base_at_detail@iostreams_at_boost@@IAEX_NAAU?$bzip2_allocator_at_V?$allocator_at_D@std@@V12@@123@@Z)
> 1>D:\Debug\BoostCompression.exe : fatal error LNK1120: 29 unresolved
> externals
>
>
> [main.cpp]
>
> --------------------------------------------------------------------------------
> #include <iostream>
> #include <sstream>
>
> #include <boost/assign/list_of.hpp>
> #include <boost/date_time/posix_time/posix_time.hpp>
> #include <boost/foreach.hpp>
> #include <boost/format.hpp>
> #include <boost/lexical_cast.hpp>
> #include <boost/numeric/conversion/cast.hpp>
> #include <boost/test/minimal.hpp>
>
> #include <boost/iostreams/copy.hpp>
> #include <boost/iostreams/device/back_inserter.hpp>
> #include <boost/iostreams/filter/bzip2.hpp>
> #include <boost/iostreams/filter/zlib.hpp>
> #include <boost/iostreams/filtering_stream.hpp>
>
> enum CompressionScheme
> {
> NO_COMPRESSION,
> ZLIB_COMPRESSION,
> BZIP2_COMPRESSION
> };
>
> typedef boost::posix_time::ptime TimeType;
>
> //----------------------------------------------------------------------------
> void
> add_compressor
> (
> boost::iostreams::filtering_streambuf<boost::iostreams::output>&
> out,
> CompressionScheme scheme
> )
> {
> switch (scheme)
> {
> case ZLIB_COMPRESSION:
> {
> out.push(boost::iostreams::zlib_compressor());
> break;
> }
> case BZIP2_COMPRESSION:
> {
> out.push(boost::iostreams::bzip2_compressor());
> break;
> }
> default:
> {
> break;
> }
> }
> }
>
> //----------------------------------------------------------------------------
> void
> add_decompressor
> (
> boost::iostreams::filtering_streambuf<boost::iostreams::input>& in,
> CompressionScheme scheme
> )
> {
> switch (scheme)
> {
> case ZLIB_COMPRESSION:
> {
> in.push(boost::iostreams::zlib_decompressor());
> break;
> }
> case BZIP2_COMPRESSION:
> {
> in.push(boost::iostreams::bzip2_decompressor());
> break;
> }
> default:
> {
> break;
> }
> }
> }
>
> //----------------------------------------------------------------------------
> std::string
> compress
> (
> const std::string& data
> )
> {
> std::stringstream compressed;
> std::stringstream decompressed;
> decompressed << data;
> boost::iostreams::filtering_streambuf<boost::iostreams::input> out;
> out.push(boost::iostreams::zlib_compressor());
> out.push(decompressed);
> boost::iostreams::copy(out, compressed);
> return compressed.str();
> }
>
> //----------------------------------------------------------------------------
> std::string
> compress1
> (
> const std::string& data,
> CompressionScheme scheme
> )
> {
> std::string compressed;
> boost::iostreams::filtering_streambuf<boost::iostreams::output> out;
> add_compressor(out, scheme);
> out.push(boost::iostreams::back_inserter(compressed));
> boost::iostreams::copy(boost::make_iterator_range(data), out);
> return compressed;
> }
>
> //----------------------------------------------------------------------------
> void
> compress2
> (
> const std::string& data,
> std::string& buffer,
> CompressionScheme scheme
> )
> {
> buffer.clear();
> boost::iostreams::filtering_streambuf<boost::iostreams::output> out;
> add_compressor(out, scheme);
> out.push(boost::iostreams::back_inserter(buffer));
> boost::iostreams::copy(boost::make_iterator_range(data), out);
> }
>
> //----------------------------------------------------------------------------
> std::string
> decompress
> (
> const std::string& data
> )
> {
> std::stringstream compressed;
> std::stringstream decompressed;
> compressed << data;
> boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
> in.push(boost::iostreams::zlib_decompressor());
> in.push(compressed);
> boost::iostreams::copy(in, decompressed);
> return decompressed.str();
> }
>
> //----------------------------------------------------------------------------
> std::string
> decompress1
> (
> const std::string& data,
> CompressionScheme scheme
> )
> {
> boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
> add_decompressor(in, scheme);
> in.push(boost::make_iterator_range(data));
> std::string decompressed;
> boost::iostreams::copy(in,
> boost::iostreams::back_inserter(decompressed));
> return decompressed;
> }
>
> //----------------------------------------------------------------------------
> void
> decompress2
> (
> const std::string& buffer,
> std::string& data,
> CompressionScheme scheme
> )
> {
> boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
> add_decompressor(in, scheme);
> in.push(boost::make_iterator_range(buffer));
> data.clear();
> boost::iostreams::copy(in, boost::iostreams::back_inserter(data));
> }
>
> //----------------------------------------------------------------------------
> TimeType
> current_time
> (
> )
> {
> return boost::posix_time::microsec_clock::local_time();
> }
>
> //----------------------------------------------------------------------------
> double
> elapsed_seconds
> (
> const TimeType& start_time
> )
> {
> static const double MSEC_PER_SEC = 1000.0;
> TimeType end_time = current_time();
> boost::posix_time::time_duration elapsed = end_time - start_time;
> return boost::numeric_cast<double>(elapsed.total_milliseconds()) /
> MSEC_PER_SEC;
> }
>
> //----------------------------------------------------------------------------
> int
> test_main
> (
> int /*argc*/,
> char* /*argv*/[]
> )
> {
> const int NUM_ITERATIONS = 10000;
> const std::string send_data = "boo! how are you?";
> const std::string base_statement = "ALGO %|1$-3s|: %2% cycles took
> %|3$0.3f| seconds";
>
> double t0;
>
> // Try original algorithm
> {
> const std::string time_statement = base_statement + " (Original)\n";
>
> TimeType start_time = current_time();
>
> std::string received_data;
> for (int i = 0; i < NUM_ITERATIONS; ++i)
> {
> const std::string buffer = compress(send_data);
> received_data = decompress(buffer);
> }
> BOOST_CHECK(send_data == received_data);
>
> t0 = elapsed_seconds(start_time);
> std::cout << (boost::format(time_statement) % 0 % NUM_ITERATIONS %
> t0);
> }
>
> const std::string improvement_statement = base_statement + "
> (Improvement %|4$5.2f| %%)\n";
>
> typedef std::vector<CompressionScheme> SchemeVectorType;
> const SchemeVectorType schemes =
>
> boost::assign::list_of(NO_COMPRESSION)(ZLIB_COMPRESSION)(BZIP2_COMPRESSION);
>
> // Try new algorithm 1
> BOOST_FOREACH(CompressionScheme scheme, schemes)
> {
> TimeType start_time = current_time();
>
> std::string received_data;
> for (int i = 0; i < NUM_ITERATIONS; ++i)
> {
> const std::string buffer = compress1(send_data, scheme);
> received_data = decompress1(buffer, scheme);
> }
> BOOST_CHECK(send_data == received_data);
>
> const std::string algo = std::string("1,") +
> boost::lexical_cast<std::string>(scheme);
>
> const double e = elapsed_seconds(start_time);
> const double improvement = ((t0 - e) / t0) * 100.0;
> std::cout << (boost::format(improvement_statement) % algo %
> NUM_ITERATIONS % e % improvement);
> }
>
> // Try new algorithm 2
> BOOST_FOREACH(CompressionScheme scheme, schemes)
> {
> TimeType start_time = current_time();
>
> std::string received_data;
> for (int i = 0; i < NUM_ITERATIONS; ++i)
> {
> std::string buffer;
> compress2(send_data, buffer, scheme);
> decompress2(buffer, received_data, scheme);
> }
> BOOST_CHECK(send_data == received_data);
>
> const std::string algo = std::string("2,") +
> boost::lexical_cast<std::string>(scheme);
>
> const double e = elapsed_seconds(start_time);
> const double improvement = ((t0 - e) / t0) * 100.0;
> std::cout << (boost::format(improvement_statement) % algo %
> NUM_ITERATIONS % e % improvement);
> }
>
> return 0;
> }
>
>
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net