C++ Boost库iostream::复制不工作
它说我得到了C++ Boost库iostream::复制不工作,c++,boost,boost-iostreams,C++,Boost,Boost Iostreams,它说我得到了boost::iostreams::bzip2::config\u错误 这是否意味着我安装的bzip2过滤器错误 因为我用的东西有些错误 #include <fstream> #include <iostream> #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/copy.hpp> #include <boost/iostre
boost::iostreams::bzip2::config\u错误
这是否意味着我安装的bzip2过滤器错误
因为我用的东西有些错误
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
int main()
{
using namespace std;
using namespace boost::iostreams;
try {
ifstream file("hello.bz2", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(bzip2_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
catch(const bzip2_error& exception) {
int error = exception.error();
if(error == boost::iostreams::bzip2::data_error) {
// compressed data stream is corrupted
cout << "compressed data stream is corrupted";
}
else if(error == boost::iostreams::bzip2::data_error_magic)
{
// compressed data stream does not begin with the 'magic' sequence 'B' 'Z' 'h'
cout << "compressed data stream does not begin with the 'magic' sequence 'B' 'Z' 'h'";
}
else if(boost::iostreams::bzip2::config_error) {
// libbzip2 has been improperly configured for the current platform
cout << "libbzip2 has been improperly configured for the current platform";
}
}
}
我得到:
b2 --toolset=msvc-10.0 -sBZIP2_SOURCE="C:\bzip2-1.0.6" --build-type=complete stage
C:\boost\u 1\u 54\u 0>b2--toolset=msvc-10.0-sBZIP2\u SOURCE=“C:\bzip2-1.0.6”--build-t
ype=完成阶段
执行配置检查
-32位:是(缓存)
-arm:否(缓存)
-mips1:否(缓存)
-电源:否(缓存)
-sparc:否(缓存)
-x86:是(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-已生成:否(缓存)
警告:图形库不包含基于MPI的并行组件。
注意:要启用它们,请在user-config.jam中添加“using mpi;”
-zlib:no(缓存)
-iconv(libc):否(缓存)
-iconv(单独):否(缓存)
-icu:否(缓存)
-icu(lib64):否(缓存)
-消息编译器:是(缓存)
-编译器-supports-ssse3:是(缓存)
-编译器-supports-avx2:否(缓存)
-gcc可见性:否(缓存)
-长双支持:是(缓存)
警告:跳过可选的消息传递接口(MPI)库。
注意:要启用MPI支持,请将“使用MPI;”添加到user-config.jam。
注意:若要抑制此消息,请将“-不带mpi”传递给bjam。
注意:否则,您可以安全地忽略此消息。
警告:未配置python安装和自动配置
注意:失败。看见http://www.boost.org/libs/python/doc/building.html
注意:对于配置指令或pass——不带python
注意:抑制此消息并静默跳过所有Boost.Python目标
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
-zlib:no(缓存)
-zlib:no(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
-zlib:no(缓存)
-zlib:no(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
错误:没有libs/coroutine/build/allocator\u源的最佳替代方案
下一个备选方案:所需属性:静态windows multi
不匹配
下一个备选方案:所需属性:多线程上的静态
不匹配
下一个备选方案:所需属性:静态多属性
不匹配
-zlib:no(缓存)
组件配置:
-原子能:建筑
-时钟:建筑物
-背景:建筑
-协同程序:构建
-日期和时间:建筑
-例外情况:建筑
-文件系统:构建
-图表:建筑
-图形并行:建筑
-iostreams:建筑
-地点:大厦
-日志:建筑
-数学:建筑
-mpi:建筑
-项目选项:建筑
-python:构建
-随机:建筑
-正则表达式:建筑物
-序列化:构建
-信号:建筑
-系统:建筑
-测试:建筑
-主题:建筑
-计时器:建筑物
-波浪:建筑物
……耐心。。。
……耐心。。。
……耐心。。。
……耐心。。。
……耐心。。。
…找到了47439个目标。。。
C:\boost\u 1\u 54\u 0>b2--toolset=msvc-10.0-
b2 --toolset=msvc-10.0 -sBZIP2_SOURCE="C:\bzip2-1.0.6" --build-type=complete stage
C:\boost_1_54_0>b2 --toolset=msvc-10.0 -sBZIP2_SOURCE="C:\bzip2-1.0.6" --build-t
ype=complete stage
Performing configuration checks
- 32-bit : yes (cached)
- arm : no (cached)
- mips1 : no (cached)
- power : no (cached)
- sparc : no (cached)
- x86 : yes (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- has_icu builds : no (cached)
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
- zlib : no (cached)
- iconv (libc) : no (cached)
- iconv (separate) : no (cached)
- icu : no (cached)
- icu (lib64) : no (cached)
- message-compiler : yes (cached)
- compiler-supports-ssse3 : yes (cached)
- compiler-supports-avx2 : no (cached)
- gcc visibility : no (cached)
- long double support : yes (cached)
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
warning: No python installation configured and autoconfiguration
note: failed. See http://www.boost.org/libs/python/doc/building.html
note: for configuration instructions or pass --without-python to
note: suppress this message and silently skip all Boost.Python targets
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
- zlib : no (cached)
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
- zlib : no (cached)
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <thre
ading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <th
reading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
Component configuration:
- atomic : building
- chrono : building
- context : building
- coroutine : building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- log : building
- math : building
- mpi : building
- program_options : building
- python : building
- random : building
- regex : building
- serialization : building
- signals : building
- system : building
- test : building
- thread : building
- timer : building
- wave : building
...patience...
...patience...
...patience...
...patience...
...patience...
...found 47439 targets...
C:\boost_1_54_0>b2 --toolset=msvc-10.0 -sBZIP2_SOURCE="C:\bzip2-1.0.6" --build-type=complete stage
Performing configuration checks
- 32-bit : yes (cached)
- arm : no (cached)
- mips1 : no (cached)
- power : no (cached)
- sparc : no (cached)
- x86 : yes (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- has_icu builds : no (cached)
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
- zlib : no (cached)
- iconv (libc) : no (cached)
- iconv (separate) : no (cached)
- icu : no (cached)
- icu (lib64) : no (cached)
- message-compiler : yes (cached)
- compiler-supports-ssse3 : yes (cached)
- compiler-supports-avx2 : no (cached)
- gcc visibility : no (cached)
- long double support : yes (cached)
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
warning: No python installation configured and autoconfiguration
note: failed. See http://www.boost.org/libs/python/doc/building.html
note: for configuration instructions or pass --without-python to
note: suppress this message and silently skip all Boost.Python targets
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
- zlib : no (cached)
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
- zlib : no (cached)
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
- zlib : no (cached)
Component configuration:
- atomic : building
- chrono : building
- context : building
- coroutine : building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- log : building
- math : building
- mpi : building
- program_options : building
- python : building
- random : building
- regex : building
- serialization : building
- signals : building
- system : building
- test : building
- thread : building
- timer : building
- wave : building
...patience...
...patience...
...patience...
...patience...
...patience...
...found 47439 targets...
if(boost::iostreams::bzip2::config_error)
libbzip2 has been improperly configured for the current platform
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/filesystem.hpp>
int main()
{
using namespace std;
using namespace boost::iostreams;
char filename[] = "gcc-4.7.2.tar.bz2";
if (!boost::filesystem::exists(filename))
{
cout << "Can't find " << filename << ". Expect errors to follow! " << endl;
}
ifstream file(filename, ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(bzip2_decompressor());
in.push(file);
try
{
boost::iostreams::copy(in, cout);
}
catch (const bzip2_error& exception)
{
cout << exception.what() << endl;
int error = exception.error();
if (error == bzip2::data_error)
{
cout << "compressed data stream is corrupted";
}
else if (error == bzip2::data_error_magic)
{
cout << "compressed data stream does not begin with the 'magic' sequence 'B' 'Z' 'h'";
}
else if (error == bzip2::config_error)
{
cout << "libbzip2 has been improperly configured for the current platform";
}
else
{
cout << "Error: " << error;
}
cout << endl;
}
}
> clang++ 18121908.cpp -lboost_iostreams -lboost_system -lboost_filesystem -o 18121908
> ./18121908
Can't find gcc-4.7.2.tar.bz2. Expect errors to follow!
bzip2 error
Error: -7
> echo 'There should be some compiler stuff in here' > gcc-4.7.2.tar
> bzip2 gcc-4.7.2.tar
> ./18121908
There should be some compiler stuff in here