我正在尝试编译使用Boost的zlib包装器的代码。但是,无论我做什么,我都无法让它发挥作用。
在我的cpp文件中,我有以下标题:
#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>
我正在使用命令进行编译:
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本身是在运行命令后使用bjam构建的:
./bootstrap.sh --prefix=/home/anon/boost --with-libraries=filesystem,program_options,system,serialization
我收到的错误消息如下:
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)'
等...
关于如何编译此代码的任何想法?如果重要,这是在Centos 5机器上。
答案 0 :(得分:1)
好的,我发现了问题。在编译Boost时,我忘了编译iostreams。
因此,构建Boost的命令应该是:
./ bootstrap.sh --prefix = / home / andyyen / boost --with-libraries = filesystem,program_options,system,serialization,iostreams