2016-07-17 5 views
3

을 IOSTREAMS :부스트이 내 컴파일 라인 컴파일 오류

g++ -std=c++11 -Wall -Wextra -g -lboost_iostreams cppfile.cpp -o bin 

그러나 나는 다음과 같은 오류가 :이 오류가 왜 그렇게 내가 understrand하지 않는 내가 -lboost_iostreams 사용

/tmp/cclste3G.o: In function `trie::write_on_disk(char*)': 
undefined reference to `boost::iostreams::zlib::default_strategy' 
undefined reference to `boost::iostreams::zlib::deflated' 
undefined reference to `boost::iostreams::zlib::default_compression' 
/tmp/cclste3G.o: In function `boost::iostreams::basic_gzip_compressor<std::allocator<char> >::basic_gzip_compressor(boost::iostreams::gzip_params const&, int)': 
/usr/include/boost/iostreams/filter/gzip.hpp:671: undefined reference to `boost::iostreams::zlib::best_compression' 
/usr/include/boost/iostreams/filter/gzip.hpp:671: undefined reference to `boost::iostreams::zlib::best_speed' 
/tmp/cclste3G.o: In function `boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >::zlib_compressor_impl(boost::iostreams::zlib_params const&)': 
/usr/include/boost/iostreams/filter/zlib.hpp:338: undefined reference to `boost::iostreams::detail::zlib_base::zlib_base()' 
/usr/include/boost/iostreams/filter/zlib.hpp:338: undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()' 
/tmp/cclste3G.o: In function `boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >::~zlib_compressor_impl()': 
/usr/include/boost/iostreams/filter/zlib.hpp:343: undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)' 
/usr/include/boost/iostreams/filter/zlib.hpp:343: undefined reference to `boost::iostreams::detail::zlib_base::~zlib_base()' 
/tmp/cclste3G.o: In function `void boost::iostreams::detail::zlib_base::init<std::allocator<char> >(boost::iostreams::zlib_params const&, bool, boost::iostreams::detail::zlib_allocator<std::allocator<char>, boost::iostreams::detail::zlib_allocator_traits<std::allocator<char> >::type>&)': 
/usr/include/boost/iostreams/filter/zlib.hpp:185: undefined reference to `boost::iostreams::detail::zlib_base::do_init(boost::iostreams::zlib_params const&, bool, void* (*)(void*, unsigned int, unsigned int), void (*)(void*, void*), void*)' 
/tmp/cclste3G.o: In function `boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >::filter(char const*&, char const*, char*&, char*, bool)': 
/usr/include/boost/iostreams/filter/zlib.hpp:350: undefined reference to `boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)' 
/usr/include/boost/iostreams/filter/zlib.hpp:351: undefined reference to `boost::iostreams::zlib::finish' 
/usr/include/boost/iostreams/filter/zlib.hpp:351: undefined reference to `boost::iostreams::zlib::no_flush' 
/usr/include/boost/iostreams/filter/zlib.hpp:351: undefined reference to `boost::iostreams::detail::zlib_base::xdeflate(int)' 
/usr/include/boost/iostreams/filter/zlib.hpp:352: undefined reference to `boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)' 
/usr/include/boost/iostreams/filter/zlib.hpp:353: undefined reference to `boost::iostreams::zlib_error::check(int)' 
/usr/include/boost/iostreams/filter/zlib.hpp:354: undefined reference to `boost::iostreams::zlib::stream_end' 
/tmp/cclste3G.o: In function `boost::iostreams::detail::zlib_compressor_impl<std::allocator<char> >::close()': 
/usr/include/boost/iostreams/filter/zlib.hpp:358: undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)' 

감사합니다.

+2

'cppfile.cpp' 다음에'-lboost_iostreams'을 입력하면 작동합니까? – SurvivalMachine

+1

@SurvivalMachine 예 작동 : D 고마워요! 어떻게 가능합니까 ^^ " – Fractale

+1

@perecastor : 링커 플래그 순서가 중요합니다. – ildjarn

답변

6

이후에 링커 플래그 -lboost_iostreams을 넣어 수정할 수 있습니다.. 순서가 중요합니다.

1
#Before all please install zlib library 
apt-get install zlib1g 
apt-get install zlib1g-dev 

#Try to add [ -lz ] option in command line 
g++ -std=c++11 -Wall -Wextra -g -lboost_iostreams -lz cppfile.cpp -o bin 

#If mentioned don't work, find exact position of libz.so and add -L option in command line 
g++ -std=c++11 -Wall -Wextra -g -lboost_iostreams -lz cppfile.cpp -o bin -L/usr/share