int main(int argc,char * argv[]) { boost::regex e("test"); return 0; } #g++ regex.cpp -I /path/to/boostroot -L/path/to/libboost_regex-gcc-1_34.a -o regex 报错: /tmp/ccf4WLI8.o(.gnu.linkonce.t._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j+0x13): In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)": : undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)" collect2: ld returned 1 exit status
头文件可以找到,但库的连接好像有问题,然而库的路径应该是对的,请问这是怎么回事?boost文档不是说的很清楚了吗?(boost_1_34_1/more/getting_started/unix-variants.html 第6节)A. You can specify the full path to each library: $ c++ -I path/to/boost_1_34_1 example.cpp -o example " ~/boost/lib/libboost_regex-gcc34-mt-d-1_34.a B. You can separately specify a directory to search (with -Ldirectory) and a library name to search for (with -llibrary,2 dropping the filename"s leading lib and trailing suffix (.a in this case):