How do I read / write gzipped files in C++?
The iostream
wrapper classes here look good, and here is a simple usage example:
gz::igzstream in(filename);
std::string line;
while(std::getline(in, line)){
std::cout << line << std::endl;
}
But I wasn't able to actually link it (although I have a /usr/lib/libz.a
). A simple
g++ test-gzstream.cpp -lz
didn't do it (undefined reference to gz::gzstreambase::~gzstreambase()
).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…