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@zlib@iostreams@boost@@3HB)
1>main.obj : error LNK2001: unresolved external symbol "int const
boost::iostreams::zlib::deflated" (?deflated@zlib@iostreams@boost@@3HB)
1>main.obj : error LNK2001: unresolved external symbol "int const
boost::iostreams::zlib::default_strategy"
(?default_strategy@zlib@iostreams@boost@@3HB)
1>main.obj : error LNK2019: unresolved external symbol "int __cdecl
test_main(int,char * * const)" (?test_main@@YAHHQAPAD@Z) referenced in
function "public: int __thiscall
boost::minimal_test::caller::operator()(void)"
(??Rcaller@minimal_test@boost@@QAEHXZ)
1>main.obj : error LNK2019: unresolved external symbol "protected:
__thiscall boost::iostreams::detail::bzip2_base::~bzip2_base(void)"
(??1bzip2_base@detail@iostreams@boost@@IAE@XZ) referenced in function
"public: __thiscall boost::iostreams::detail::bzip2_compressor_impl (void)"
(??1?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "protected:
__thiscall boost::iostreams::detail::zlib_base::~zlib_base(void)"
(??1zlib_base@detail@iostreams@boost@@IAE@XZ) referenced in function
__unwindfunclet$??0?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@ABUzlib_params@23@@Z$0
1>main.obj : error LNK2019: unresolved external symbol "protected:
__thiscall boost::iostreams::detail::zlib_base::zlib_base(void)"
(??0zlib_base@detail@iostreams@boost@@IAE@XZ) referenced in function
"public: __thiscall boost::iostreams::detail::zlib_compressor_impl [main.cpp]
--------------------------------------------------------------------------------
#include <iostream>
#include <sstream>
#include
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@zlib@iostreams@boost@@3HB) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::deflated" (?deflated@zlib@iostreams@boost@@3HB) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::default_strategy" (?default_strategy@zlib@iostreams@boost@@3HB) 1>main.obj : error LNK2019: unresolved external symbol "int __cdecl test_main(int,char * * const)" (?test_main@@YAHHQAPAD@Z) referenced in function "public: int __thiscall boost::minimal_test::caller::operator()(void)" (??Rcaller@minimal_test@boost@@QAEHXZ) 1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::iostreams::detail::bzip2_base::~bzip2_base(void)" (??1bzip2_base@detail@iostreams@boost@@IAE@XZ) referenced in function "public: __thiscall boost::iostreams::detail::bzip2_compressor_impl
::~bzip2_compressor_impl (void)"
(??1?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@XZ) 1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::iostreams::detail::zlib_base::~zlib_base(void)" (??1zlib_base@detail@iostreams@boost@@IAE@XZ) referenced in function __unwindfunclet$??0?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@ABUzlib_params@23@@Z$0 1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::iostreams::detail::zlib_base::zlib_base(void)" (??0zlib_base@detail@iostreams@boost@@IAE@XZ) referenced in function "public: __thiscall boost::iostreams::detail::zlib_compressor_impl
::zlib_compressor_impl (struct boost::iostreams::zlib_params const &)"
(??0?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@ABUzlib_params@23@@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::iostreams::detail::zlib_base::reset(bool,bool)" (?reset@zlib_base@detail@iostreams@boost@@IAEX_N0@Z) referenced in function "public: __thiscall boost::iostreams::detail::zlib_compressor_impl
::~zlib_compressor_impl (void)"
(??1?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@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@detail@iostreams@boost@@IAE@ABUbzip2_params@23@@Z) referenced in function "public: __thiscall boost::iostreams::detail::bzip2_compressor_impl
::bzip2_compressor_impl
(struct boost::iostreams::bzip2_params const &)" (??0?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE@ABUbzip2_params@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@zlib_base@detail@iostreams@boost@@AAEXABUzlib_params@34@_NP6APAXPAXII@ZP6AX22@Z2@Z) referenced in function "protected: void __thiscall boost::iostreams::detail::zlib_base::init
(struct boost::iostreams::zlib_params const &,bool,struct
boost::iostreams::detail::zlib_allocator
&)" (??$init@V?$allocator@D@std@@@zlib_base@detail@iostreams@boost@@IAEXABUzlib_params@23@_NAAU?$zlib_allocator@V?$allocator@D@std@@V12@@123@@Z) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::stream_end" (?stream_end@zlib@iostreams@boost@@3HB) 1>main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl boost::iostreams::zlib_error::check(int)" (?check@zlib_error@iostreams@boost@@SAXH@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::zlib_compressor_impl ::filter(char const * &,char const *,char * &,char *,bool)" (?filter@?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::iostreams::detail::zlib_base::after(char const * &,char * &,bool)" (?after@zlib_base@detail@iostreams@boost@@IAEXAAPBDAAPAD_N@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::zlib_compressor_impl ::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: int __thiscall boost::iostreams::detail::zlib_base::deflate(int)" (?deflate@zlib_base@detail@iostreams@boost@@IAEHH@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::zlib_compressor_impl
::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::no_flush" (?no_flush@zlib@iostreams@boost@@3HB) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::finish" (?finish@zlib@iostreams@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@zlib_base@detail@iostreams@boost@@IAEXAAPBDPBDAAPADPAD@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::zlib_compressor_impl
::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$zlib_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::bzip2::stream_end" (?stream_end@bzip2@iostreams@boost@@3HB) 1>main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl boost::iostreams::bzip2_error::check(int)" (?check@bzip2_error@iostreams@boost@@SAXH@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::bzip2_compressor_impl
::filter(char const * &,char const *,char * &,char *,bool)" (?filter@?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::iostreams::detail::bzip2_base::after(char const * &,char * &)" (?after@bzip2_base@detail@iostreams@boost@@IAEXAAPBDAAPAD@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::bzip2_compressor_impl ::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: int __thiscall boost::iostreams::detail::bzip2_base::compress(int)" (?compress@bzip2_base@detail@iostreams@boost@@IAEHH@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::bzip2_compressor_impl
::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::bzip2::run" (?run@bzip2@iostreams@boost@@3HB) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::bzip2::finish" (?finish@bzip2@iostreams@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@bzip2_base@detail@iostreams@boost@@IAEXAAPBDPBDAAPADPAD@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::bzip2_compressor_impl
::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: int __thiscall boost::iostreams::detail::zlib_base::inflate(int)" (?inflate@zlib_base@detail@iostreams@boost@@IAEHH@Z) referenced in function "public: bool __thiscall boost::iostreams::detail::zlib_decompressor_impl
::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$zlib_decompressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::sync_flush" (?sync_flush@zlib@iostreams@boost@@3HB) 1>main.obj : error LNK2019: unresolved external symbol "protected: int __thiscall boost::iostreams::detail::bzip2_base::decompress(void)" (?decompress@bzip2_base@detail@iostreams@boost@@IAEHXZ) referenced in function "public: bool __thiscall boost::iostreams::detail::bzip2_decompressor_impl
::filter(char const * &,char const *,char * &,char *,bool)"
(?filter@?$bzip2_decompressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QAE_NAAPBDPBDAAPADPAD_N@Z) 1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::iostreams::detail::bzip2_base::end(bool)" (?end@bzip2_base@detail@iostreams@boost@@IAEX_N@Z) referenced in function "public: void __thiscall boost::iostreams::detail::bzip2_compressor_impl
::close(void)"
(?close@?$bzip2_compressor_impl@V?$allocator@D@std@@@detail@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@bzip2_base@detail@iostreams@boost@@AAEX_NP6APAXPAXHH@ZP6AX11@Z1@Z) referenced in function "protected: void __thiscall boost::iostreams::detail::bzip2_base::init
(bool,struct boost::iostreams::detail::bzip2_allocator
std::allocator<char>,class std::allocator<char> > &)" (??$init@V?$allocator@D@std@@@bzip2_base@detail@iostreams@boost@@IAEX_NAAU?$bzip2_allocator@V?$allocator@D@std@@V12@@123@@Z) 1>D:\Debug\BoostCompression.exe : fatal error LNK1120: 29 unresolved externals
[main.cpp]
-------------------------------------------------------------------------------- #include <iostream> #include <sstream>
#include
#include #include #include #include #include #include #include
#include #include #include #include enum CompressionScheme { NO_COMPRESSION, ZLIB_COMPRESSION, BZIP2_COMPRESSION };
typedef boost::posix_time::ptime TimeType;
//---------------------------------------------------------------------------- void add_compressor ( boost::iostreams::filtering_streambufboost::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_streambufboost::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_streambufboost::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_streambufboost::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_streambufboost::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_streambufboost::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_streambufboost::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_streambufboost::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_caststd::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_caststd::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; }
participants (2)
-
ChristinaDRS
-
Sebastian Korf