2011-10-10 23 views
5

Ben Boost Gzip filtreleri sayfasından örnek derlemek çalışıyorum: hata verir ++Boost Gzip filtreler: failes derlemek

Ne yazık ki
#include <fstream> 
#include <iostream> 
#include <boost/iostreams/filtering_streambuf.hpp> 
#include <boost/iostreams/copy.hpp> 
#include <boost/iostreams/filter/gzip.hpp> 

int main() 
{ 
    using namespace std; 

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

benim g:

gzlib.cpp: In function ‘int main()’: 
gzlib.cpp:12:3: error: ‘filtering_streambuf’ was not declared in this scope 
gzlib.cpp:12:23: error: ‘input’ was not declared in this scope 
gzlib.cpp:12:30: error: ‘in’ was not declared in this scope 
gzlib.cpp:13:29: error: ‘gzip_decompressor’ was not declared in this scope 

Bunun fonksiyonu ve nasıl yanlış olan çalışmasını sağlamak için değiştir Çok teşekkürler!

Bağlantı Gzip filtreleri Artıracak: http://www.boost.org/doc/libs/release/libs/iostreams/doc/classes/gzip.html

cevap

8

sorun filtering_streambuf, input veya gzip_decompressor bakmak için de ad alanını olmamasıdır. Dene: belgelerinde tanıtılan

Tüm sınıflar, fonksiyonlar ve şablonları vardır:

#include <fstream> 
#include <iostream> 
#include <boost/iostreams/filtering_streambuf.hpp> 
#include <boost/iostreams/copy.hpp> 
#include <boost/iostreams/filter/gzip.hpp> 

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

example bu yapmaz nedeni introduction kurulan kongre olduğunu Aksi belirtilmedikçe ad alanı desteği :: iostreams. Ad alanı niteliği genellikle ihmal edilir.

+0

Çok fazla hata var, bu yüzden çıktıları çıktıya yapıştırdım. Benim Boost'um yanlış olabilir mi? http://pastebin.com/fG2ZqpaJ – ghostmansd

+0

@ghostmansd: [Burada] belirtildiği gibi (http://www.boost.org/doc/libs/release/libs/iostreams/doc/classes/gzip.html#installation), Bunun çalışması için 'zlib'e bağlanmanız gerekir. 'zlib'' boost' için haricidır, ancak genellikle UNIX sistemlerinde önceden yüklenir ve aksi halde buradan indirebilirsiniz (http://zlib.net/). – Mankarse

+0

-lz kullanarak derledim, ancak yardımcı olmuyor. – ghostmansd