XCode 프로젝트에서 boost를 사용하기 위해 정규식을 사용하여 정말 간단한 부스트 샘플을 작성하려고합니다. 몇 가지 이상한 문제가 있습니다.XCode를 사용하여 간단한 boost :: regex 샘플을 만들 수 없습니다. 4.6.3
첫째, 다음, 부스트 1.53.0 다운로드 부트 스트랩 다음 명령을 사용하여 내장 :
:./b2 install
./bootstrap.sh --with-libraries=regex
#include <iostream>
#include <boost/regex.hpp>
int main(int argc, const char * argv[])
{
std::string text(" 192.168.0.1 abc 10.0.0.255 10.5.1 1.2.3.4a 5.4.3.2 ");
const char* pattern =
"\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
"\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
"\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
"\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b";
boost::regex ip_regex(pattern);
boost::sregex_iterator it(text.begin(), text.end(), ip_regex);
boost::sregex_iterator end;
for (; it != end; ++it) {
std::cout << it->str() << "\n";
// v.push_back(it->str()); or something similar
}
return 0;
}
내가 빌드 한 정적 라이브러리 (boost_regex.a)를 프로젝트 설정 Build Phase undee에 추가했습니다. r "Library With Binary With Libraries"또한 빌드 설정 "Library Search Paths"를 .a 파일이있는 라이브러리를 가리 키도록 암시 적으로 업데이트했습니다.
빌드 할 때 표준 C++ 라이브러리처럼 보이는 링커 오류가 발생합니다. 스 니펫은 다음과 같습니다.
"__gnu_debug::_Safe_sequence_base::_M_detach_all()", referenced from:
__gnu_debug::_Safe_sequence_base::~_Safe_sequence_base() in libboost_regex.a(cregex.o)
__gnu_debug::_Safe_sequence_base::~_Safe_sequence_base() in libboost_regex.a(instances.o)
__gnu_debug::_Safe_sequence_base::~_Safe_sequence_base() in libboost_regex.a(posix_api.o)
__gnu_debug::_Safe_sequence_base::~_Safe_sequence_base() in libboost_regex.a(wide_posix_api.o)
__gnu_debug::_Safe_sequence_base::~_Safe_sequence_base() in libboost_regex.a(winstances.o)
"__gnu_debug::_Error_formatter::_M_message(__gnu_debug::_Debug_msg_id) const", referenced from:
boost::re_detail::character_pointer_range<char> const* std::lower_bound<boost::re_detail::character_pointer_range<char> const*, boost::re_detail::character_pointer_range<char> >(boost::re_detail::character_pointer_range<char> const*, boost::re_detail::character_pointer_range<char> const*, boost::re_detail::character_pointer_range<char> const&) in libboost_regex.a(c_regex_traits.o)
bool std::equal<char const*, char const*>(char const*, char const*, char const*) in libboost_regex.a(c_regex_traits.o)
std::lexicographical_compare(char const*, char const*, char const*, char const*) in libboost_regex.a(c_regex_traits.o)
bool std::lexicographical_compare<signed char const*, signed char const*>(signed char const*, signed char const*, signed char const*, signed char const*) in libboost_regex.a(c_regex_traits.o)
std::string::replace(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, char const*, char const*) in libboost_regex.a(c_regex_traits.o)
std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > >::erase(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > >, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > >) in libboost_regex.a(cregex.o)
std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > >::erase(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > >, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > >) in libboost_regex.a(cregex.o)
...
"__gnu_debug::_Error_formatter::_M_error() const", referenced from:
boost::re_detail::character_pointer_range<char> const* std::lower_bound<boost::re_detail::character_pointer_range<char> const*, boost::re_detail::character_pointer_range<char> >(boost::re_detail::character_pointer_range<char> const*, boost::re_detail::character_pointer_range<char> const*, boost::re_detail::character_pointer_range<char> const&) in libboost_regex.a(c_regex_traits.o)
bool std::equal<char const*, char const*>(char const*, char const*, char const*) in libboost_regex.a(c_regex_traits.o)
std::lexicographical_compare(char const*, char const*, char const*, char const*) in libboost_regex.a(c_regex_traits.o)
bool std::lexicographical_compare<signed char const*, signed char const*>(signed char const*, signed char const*, signed char const*, signed char const*) in libboost_regex.a(c_regex_traits.o)
std::string::replace(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, char const*, char const*) in libboost_regex.a(c_regex_traits.o)
std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > >::erase(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > >, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > >) in libboost_regex.a(cregex.o)
std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > >::erase(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > >, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > >) in libboost_regex.a(cregex.o)
...
"__gnu_debug::_Safe_iterator_base::_M_singular() const", referenced from:
__gnu_debug::_Safe_iterator<std::__norm::_List_iterator<std::string>, std::__debug::list<std::string, std::allocator<std::string> > >::operator=(__gnu_debug::_Safe_iterator<std::__norm::_List_iterator<std::string>, std::__debug::list<std::string, std::allocator<std::string> > > const&) in libboost_regex.a(cregex.o)
bool __gnu_debug::operator!=<std::__norm::_List_iterator<std::string>, std::__debug::list<std::string, std::allocator<std::string> > >(__gnu_debug::_Safe_iterator<std::__norm::_List_iterator<std::string>, std::__debug::list<std::string, std::allocator<std::string> > > const&, __gnu_debug::_Safe_iterator<std::__norm::_List_iterator<std::string>, std::__debug::list<std::string, std::allocator<std::string> > > const&) in libboost_regex.a(cregex.o)
bool __gnu_debug::operator==<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > >(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > > const&, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, long> >, std::__debug::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > > > const&) in libboost_regex.a(cregex.o)
bool __gnu_debug::operator==<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > >(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > > const&, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > > const&) in libboost_regex.a(cregex.o)
bool __gnu_debug::operator!=<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > >(__gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > > const&, __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, std::string> >, std::__debug::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > > > const&) in libboost_regex.a(cregex.o)
이 문제의 원인은 누구입니까? 어떤 간단한 테스트 케이스도 생각할 수 없다. ...