user788171
user788171

Reputation: 17553

compiling boost with zlib on Linux

I am trying to compile a code that uses Boost's zlib wrappers. However, no matter what I do, I can't get this to work.

In my cpp file, I have the following headers:

#include <algorithm>
#include <fstream>
#include <vector>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include <boost/iostreams/filtering_stream.hpp>

I am compiling using command:

g++ -O3 -ffast-math -funroll-loops -ansi -pedantic-errors -L/usr/lib -lboost_filesystem -lboost_serialization -lz -I /usr/include/boost -o zlib_test zlib_test.o

Boost itself was built with bjam after running command:

./bootstrap.sh --prefix=/home/anon/boost --with-libraries=filesystem,program_options,system,serialization

The error message I am getting is the following:

zlib_test.o: In function `boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::dispose()':
zlib_test.cpp:(.text._ZN5boost6detail17sp_counted_impl_pINS_9iostreams16symmetric_filterINS2_6detail20zlib_compressor_implISaIcEEES6_E4implEE7disposeEv[boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::dispose()]+0x30): undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'

etc....

Any ideas on how I can get this code to compile? If it matters, this is on a Centos 5 machine.

Upvotes: 1

Views: 3631

Answers (1)

user788171
user788171

Reputation: 17553

Ok, I found out the problem. When compiling Boost, I forgot to compile iostreams.

Thus, the command to build Boost should be:

./bootstrap.sh --prefix=/home/andyyen/boost --with-libraries=filesystem,program_options,system,serialization,iostreams

Upvotes: 1

Related Questions