comment faire un lien bibliothèque zlib

Salut, je suis d'utilisation de boost et zlib filtre pour compresser et décompresser des données. sur les instructions de boost page, c'est dire
si l' .fichier cpp dépend d'une bibliothèque externe, vous devez la créer à partir de la source ou un lien binaires pré-compilés.

J'ai utilisé mac port pour installer boost et zlib. Je comprend le coup de pouce bibliothèque comme
-I/opt/local/include

mon code:

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

int main() 
{
    using namespace std;

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

Je me demande comment lier les pré-construit zlib externe bibliothèque? il me donne cette compilation de problème:

mpic++ -o local ods_v2.0.cpp -I/opt/local/include
Undefined symbols for architecture x86_64:
"boost::iostreams::zlib_error::check(int)", referenced from:
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, char*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
"boost::iostreams::zlib::stream_end", referenced from:
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, char*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
"boost::iostreams::zlib::sync_flush", referenced from:
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, char*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
"boost::iostreams::zlib::default_strategy", referenced from:
boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::make_params(int) in ods_v2-DjDcji.o
"boost::iostreams::zlib::default_compression", referenced from:
boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::make_params(int) in ods_v2-DjDcji.o
"boost::iostreams::zlib::okay", referenced from:
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char*, long) in ods_v2-DjDcji.o
"boost::iostreams::zlib::deflated", referenced from:
boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::make_params(int) in ods_v2-DjDcji.o
"boost::iostreams::detail::gzip_footer::reset()", referenced from:
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char*, long) in ods_v2-DjDcji.o
boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::basic_gzip_decompressor(int, int) in ods_v2-DjDcji.o
"boost::iostreams::detail::gzip_footer::process(char)", referenced from:
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char*, long) in ods_v2-DjDcji.o
"boost::iostreams::detail::gzip_header::reset()", referenced from:
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char*, long) in ods_v2-DjDcji.o
boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::basic_gzip_decompressor(int, int) in ods_v2-DjDcji.o
"boost::iostreams::detail::gzip_header::process(char)", referenced from:
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
long boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char*, long) in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)", referenced from:
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, char*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::reset(bool, bool)", referenced from:
boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close_impl() in ods_v2-DjDcji.o
boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl::impl<boost::iostreams::zlib_params>(int, boost::iostreams::zlib_params const&) in ods_v2-DjDcji.o
boost::detail::shared_count::shared_count<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl>(boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl*) in ods_v2-DjDcji.o
boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::dispose() in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)", referenced from:
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, char*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::do_init(boost::iostreams::zlib_params const&, bool, void* (*)(void*, unsigned int, unsigned int), void (*)(void*, void*), void*)", referenced from:
boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl::impl<boost::iostreams::zlib_params>(int, boost::iostreams::zlib_params const&) in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::xinflate(int)", referenced from:
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::write<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, char const*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, char*, long) in ods_v2-DjDcji.o
void boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::close<boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > > >(boost::iostreams::basic_gzip_decompressor<std::allocator<char> >::peekable_source<boost::iostreams::detail::linked_streambuf<char, std::char_traits<char> > >&, std::_Ios_Openmode) in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::zlib_base()", referenced from:
boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl::impl<boost::iostreams::zlib_params>(int, boost::iostreams::zlib_params const&) in ods_v2-DjDcji.o
"boost::iostreams::detail::zlib_base::~zlib_base()", referenced from:
boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl::impl<boost::iostreams::zlib_params>(int, boost::iostreams::zlib_params const&) in ods_v2-DjDcji.o
boost::detail::shared_count::shared_count<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl>(boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl*) in ods_v2-DjDcji.o
boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_decompressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::dispose() in ods_v2-DjDcji.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [local] Error 1

et comment le construire et le lien de boost et de la bibliothèque zlib sur unix cluster? merci.

Vous devriez être en mesure de préciser -lz sur la gcc en ligne de commande
Ctrl+k pour indenter le code/sortie de ligne de commande.
c'est toujours la même erreur...je suis en utilisant mpi..

OriginalL'auteur weeo | 2013-04-01