1
我无法获得boost程序编译。我试图编译的例子是在这里:http://rosettacode.org/wiki/Web_scraping#C.2B.2Bboost :: asio :: streambuf - 链接器错误
这是当我尝试编译会发生什么:
% 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
我想我已经缩小问题到这一行:
boost::asio::streambuf response ;
我用gcc 4.6.0,当然Linux的:
% 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)
可能相关的主题:
Code using boost::asio::streambuf causes segfault
为我编译和运行。 gcc 4.5.2,gcc 4.6.0,boost 1.42,boost 1.46。 – Cubbi 2011-06-01 20:32:02
在包含任何Boost标头之前,尝试在源文件中添加'#include'。这个错误让我觉得它只是试图捕捉这个类的前向声明。 –
ildjarn
2011-06-01 20:33:25
@ildjarn不行。和以前一样的错误信息。我使用boost 1.46,顺便说一句。 – g33kz0r 2011-06-01 20:46:06