Je rencontre des problèmes pour compiler un programme. L'exemple que je suis en train de compiler est ici: http://rosettacode.org/wiki/Web_scraping#C.2B.2Bboost :: asio :: streambuf - erreur de lien
Ce qui se passe quand je tente de compiler:
% g++ -Wall test.c -lboost_regex -lboost_system -lboost_thread
/tmp/ccJSxOji.o: In function `boost::exception_detail::error_info_injector<std::length_error>::error_info_injector(boost::exception_detail::error_info_injector<std::length_error> const&)':
test.c:(.text._ZN5boost16exception_detail19error_info_injectorISt12length_errorEC2ERKS3_[_ZN5boost16exception_detail19error_info_injectorISt12length_errorEC5ERKS3_]+0x53): undefined reference to `std::length_error::~length_error()'
/tmp/ccJSxOji.o: In function `boost::exception_detail::error_info_injector<std::length_error>::~error_info_injector()':
test.c:(.text._ZN5boost16exception_detail19error_info_injectorISt12length_errorED2Ev[_ZN5boost16exception_detail19error_info_injectorISt12length_errorED5Ev]+0x2e): undefined reference to `std::length_error::~length_error()'
collect2: ld returned 1 exit status
Je pense que je l'ai réduit le problème à cette ligne:
boost::asio::streambuf response ;
J'utilise gcc 4.6.0, linux bien sûr:
% gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /build/src/gcc-4.6-20110429/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --disable-multilib --disable-libstdcxx-pch --enable-checking=release
Thread model: posix
gcc version 4.6.0 20110429 (prerelease) (GCC)
fil Peut-être lié:
Code using boost::asio::streambuf causes segfault
Compile et fonctionne pour moi. gcc 4.5.2, gcc 4.6.0, boost 1.42, boost 1.46. – Cubbi
Essayez d'ajouter '#include' au fichier source avant d'inclure les en-têtes Boost. L'erreur me fait penser qu'il essaie d'attraper avec seulement une déclaration avant de la classe. –
ildjarn
@ildjarn Non, allez-y. Même message d'erreur que précédemment. J'utilise boost 1.46, btw. – g33kz0r