Does Ubuntu 18.04 boost include lzma support?

400 Views Asked by At

I have a piece of C++ software that uses a bzip2 decompressor on a boost::iostreams::filtering_istreambuf. This works well.

I now tried to change it to also support lzma decompression. The corresponding include file seems to be there in my ubuntu 18.04 installation:

$ ls -al /usr/include/boost/iostreams/filter/
-rw-r--r-- 1 root root 13199 Mar  6  2018 bzip2.hpp
-rw-r--r-- 1 root root 24804 Mar  6  2018 gzip.hpp
-rw-r--r-- 1 root root 12157 Mar  6  2018 lzma.hpp
-rw-r--r-- 1 root root 14650 Mar  6  2018 zlib.hpp
(shortened)

However, the code does not link, I get error messages as follows:

In function `boost::iostreams::detail::lzma_decompressor_impl<std::allocator<char> >::lzma_decompressor_impl()':
test2.cpp:(.text._ZN5boost9iostreams6detail22lzma_decompressor_implISaIcEEC2Ev[_ZN5boost9iostreams6detail22lzma_decompressor_implISaIcEEC5Ev]+0x24): undefined reference to `boost::iostreams::detail::lzma_base::lzma_base()'
(etc)

I now wonder whether the shipped boost library was built without lzma support (but then why is there an lzma include file?). More generally, I wonder whether (and how) I can check the build options that were used for the boost library that was shipped.

I understand I can built my boost library from scratch, but would only do this if I really need to.

Update: My code is more complex, but below is a minimum example essentially taken from here that demonstrates the problem:

This works:

#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <fstream>
#include <iostream>

namespace io = boost::iostreams;

void foo(std::string input_file_path, std::string output_file_path) {
    namespace io = boost::iostreams;

    std::ifstream file(input_file_path, std::ios::binary);
    std::ofstream out(output_file_path, std::ios::binary);

    boost::iostreams::filtering_istreambuf in;
    in.push(io::bzip2_decompressor());
    in.push(file);

    io::copy(in, out);
}

int main() {
    foo("test.cpp.bz2", "output.txt");
}

This does not compile (with g++ test.cpp -lboost_iostreams):

#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/lzma.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <fstream>
#include <iostream>

namespace io = boost::iostreams;

void foo(std::string input_file_path, std::string output_file_path) {
    namespace io = boost::iostreams;

    std::ifstream file(input_file_path, std::ios::binary);
    std::ofstream out(output_file_path, std::ios::binary);

    boost::iostreams::filtering_istreambuf in;
    in.push(io::lzma_decompressor());
    in.push(file);

    io::copy(in, out);
}

int main() {
    foo("test.cpp.lzma", "output.txt");
}
0

There are 0 best solutions below