gpt4 book ai didi

c++ - 在 Windows 上使用 zlib 编译 boost

转载 作者:太空宇宙 更新时间:2023-11-04 11:35:47 24 4
gpt4 key购买 nike

是否有关于如何在 Windows 上使用 zlib 编译 boost 的好教程。我查看了 boost 引用资料,但它含糊不清而且还不够。我确实下载了 zlib dll 和源代码,并在 visual studio 中进行了引用。我在

上有链接错误
gzip_decompressor();

完整代码:

using namespace boost::iostreams;
using namespace std;
std::ifstream file("hello.gz", std::ios_base::in | std::ios_base::binary);
filtering_streambuf < input > in;
in.push(gzip_decompressor());
in.push(file);
boost::iostreams::copy(in, std::cout);

我收到这个错误,

Error 11 error LNK2019: unresolved external symbol "_declspec(dllimport) public: __thiscall boost::iostreams::detail::gzip_header::~gzip_header(void)" (__imp??1gzip_header@detail@iostreams@boost@@QAE@XZ) referenced in function "public: __thiscall boost::iostreams::basic_gzip_decompressor \>::~basic_gzip_decompressor >(void)" (??1?$basic_gzip_decompressor@V?$allocator@D@std@@@iostreams@boost@@QAE@XZ) –

最佳答案

链接器实际上告诉您它找不到“basic_gzip_decompressor”。原因是因为您的 boost 库中没有内置了 zlib。

(This SO question 声称有一个解决方案无需将 zlib 构建到 boost 库中)

我同意这方面的文档有点简洁,但它是 found here .如果您的正常构建命令行是这样的:

b2 -j15 --toolset=msvc --build-type=complete stage 

添加 ZLIB 定义以使其使用 zlib 构建

b2 -j15 --toolset=msvc --build-type=complete stage -s ZLIB_SOURCE="C:\zlib-1.2.8" -s ZLIB_INCLUDE="C:\zlib-1.2.8" 

当您查找配置检查输出时,您可以相对快速地检查它是否有效(在编译完成之前)。那里应该说这样的话:

- zlib               : yes  (cached)

关于c++ - 在 Windows 上使用 zlib 编译 boost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23107703/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com