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