开发者

Why is Boost crashing during a simple build?

I am trying to use Eclipse / Windows 7 / boost following http://theseekersquill.wordpress.com/2010/08/24/howto-boost-mingw/. I am getting crash because there are two days and I can't do a simple debug yet. I am getting this error on build. Any suggestions will be appreciated.

**** Internal Builder is used for build               ****
g++ -LC:\boost_1_47_0\stage\lib -o TesteMinGW.exe regex.o -lboost_regex-mgw44-1_47  
cygwin warning:  
  MS-DOS style path detected: C:\boost_1_47_0\stage\lib/libboost_regex-mgw44-1_47.dll.a  
  Preferred POSIX equivalent is: /cygdrive/c/boost_1_47_0/stage/lib/libboost_regex-mgw44-1_47.dll.a  
  CYGWIN environment variable option "nodosfilewarni开发者_StackOverflow社区ng" turns off this warning.  
  Consult the user's guide for more details about POSIX paths:  
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames  
regex.o: In function '_ZThn28_NK5boost16exception_detail10clone_implINS0_19error_info_injectorISt11logic_errorEEE5cloneEv':  
C:/boost_1_47_0/boost/exception/exception.hpp:  (.text$_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[bool boost::regex_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, char, boost::regex_traits<char, boost::c_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::c_regex_traits<char> > > const&, boost::regex_constants::_match_flags)]+0x9a): undefined reference to 'boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::c_regex_traits<char> > >::match()'
C:/boost_1_47_0/boost/exception/exception.hpp:(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char, boost::regex_traits<char, boost::c_regex_traits<char> > >::assign(char const*, char const*, unsigned int)]+0x22): undefined reference to 'boost::basic_regex<char, boost::regex_traits<char, boost::c_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
regex.o: In function 'main':
/cygdrive/c/_D/WorkSpaces/ws_C_Dev/TesteMinGW/Debug/..\regex.cpp:6: undefined reference to 'boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::c_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::c_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
collect2: ld returned 1 exit status
Build error occurred, build is stopped


You're getting a link error. Either check that all parts of the library are being built with the same flags (check the environment, or if you reconfigured (boostrap), clean your build directories up).

If all that fails, it really seems time for a bug report, if your build configuration is supported (haven't checked).

The thing that is likely happening by that point in diagnostics, is that template instantiations are being elided as symbols with external linkage. Fixing that can be quite tricky, especially in a larger body like Boost.Regex, that needs to be highly portable[1].

Anyways, usually there is something like this

template <typename X>
struct Y
{
     int getsomething();
};

in the header (hpp). And you'd need to have

template struct Y<MyInstantiation1>;
template struct Y<MyInstantiation2>;
template struct Y<MyInstantiation3>;

in a single compilation unit (that also contains the definition(s) of Y<>::getsomething) in order to give those external linkage.

This is a best guess, and I haven't looked at the error for lack of time.

[1] that seems to be the exactly how this problem can creep in

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜