- 論壇徽章:
- 0
|
在C/C++版塊沒有獲得答案,轉(zhuǎn)到這里來
下載后源碼用Easy Build and Install
./configure --prefix=/usr/local/boost --without-icu
之后抄了個文檔的上一個例子,編譯鏈接都沒有問題,運行后直接出現(xiàn)
Segmentation fault
我用的系統(tǒng)是 Fedora core 7 gcc-4.1.2
boost 安裝在 /usr/local/boost 下
Linux下編譯參數(shù)
g++ xxx.cpp -o test -L/usr/local/boost/lib -l/boost_regex-gcc41-mt-d-1_34_1
測試代碼
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
在Windows 下運行沒有問題 |
|