使用boost regex C ++进行编译

时间:2017-01-23 01:34:52

标签: c++ boost

之前我在旧计算机上使用了boost :: regex,但现在我无法弄清楚如何使用它。

我有链接器问题,我得到了:

||=== Build: Release in regex test (compiler: GNU GCC Compiler) ===|
C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a(regex.o)||duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size|
C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a(regex.o)||duplicate section `.rdata$_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE[__ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE]' has different size|
C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a(regex.o)||duplicate section `.rdata$_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size|
C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a(regex.o)||duplicate section `.rdata$_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE[__ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE]' has different size|
C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a(cpp_regex_traits.o)||duplicate section `.data$_ZZN5boost16cpp_regex_traitsIcE21get_catalog_name_instEvE6s_name[__ZZN5boost16cpp_regex_traitsIcE21get_catalog_name_instEvE6s_name]' has different size|
obj\Release\main.o:main.cpp:(.text$_ZNK5boost16re_detail_10630031cpp_regex_traits_implementationIcE18lookup_collatenameEPKcS4_[__ZNK5boost16re_detail_10630031cpp_regex_traits_implementationIcE18lookup_collatenameEPKcS4_]+0x80)||undefined reference to `boost::re_detail_106300::lookup_default_collate_name(std::string const&)'|
obj\Release\main.o:main.cpp:(.text$_ZN5boost16re_detail_10630018basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE4failENS_15regex_constants10error_typeEiSsi[__ZN5boost16re_detail_10630018basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE4failENS_15regex_constants10error_typeEiSsi]+0x1d4)||undefined reference to `boost::regex_error::regex_error(std::string const&, boost::regex_constants::error_type, int)'|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 5 warning(s) (0 minute(s), 0 second(s)) ===|

代码是这样的:

#include <boost/regex.hpp>

int main()
{
    boost::regex test("test");
    return 0;
}

我正在关联C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a,搜索目录为C:\boost

我正在使用代码块编译您的信息。

我使用mingw / gcc编译或“制作”了libs,实际上我尝试了很多东西......我也下载并安装了mingw,即使我已经使用了Code Blocks,并且我“制作”了libs与我之后安装的libs。 (mingw的路径设置为那里)。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,我发布它以防万一它可以帮助其他人。

问题是因为我手动下载了MinGW并且用它来编译libs,我正在用Code Blocks的MinGW编译我的程序。他们可能有不同的版本,这确实是问题。