0

I used boost::regex before, on my old computer, but now I can't figure out how to be able to use it.

I have problems with the linker, I'm getting :

||=== 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)) ===|

The code is this :

#include <boost/regex.hpp>

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

I am linking C:\boost\stage\lib\libboost_regex-mgw53-mt-1_63.a, and the search directory is C:\boost.

I am compiling using Code Blocks for your info.

I compiled, or "made" the libs with mingw/gcc, and actually I tried a lot of things... I also downloaded and installed mingw, even if I already had it with Code Blocks, and I "made" the libs with the one I installed later. (the path for mingw is set to there).

Neox
  • 279
  • 3
  • 13
  • 1
    Looks like conflicting compiler versions/flags. – sehe Jan 23 '17 at 01:42
  • @Neox, you can use std::regex instead of boost::regex. It was added in C++ 11. – Deedee Megadoodoo Jan 23 '17 at 02:06
  • @sehe can you be more precise please? I think the problem comes from me compiling the libs with mingw manually downloaded, and compiling the project with code block's mingw. Do you think that this is the problem? – Neox Jan 23 '17 at 02:34
  • @Real Fresh as far as I remember, the syntax for std regex isn't the same. Anyway I already have a project with over 6000 lines, coded on my old computer with boost regex... :/ – Neox Jan 23 '17 at 02:34
  • @RealFresh many compilers didn't include proper implementations until years after they claimed c++11 support (it was gruesome). I'd not change boats midstream. – sehe Jan 23 '17 at 02:35
  • @Neox can __you__ be more precise? Please include SSCCE, precise build steps (including your boost). Alternatively, just get a working setup from the nets (https://nuwen.net/mingw.html) – sehe Jan 23 '17 at 02:37
  • @sehe Well, I tried this : http://stackoverflow.com/questions/13256788/building-boost-1-52-with-mingw/13257930#13257930 (this was supposed to work, i saved it when i managed to make it work on my old computer, to set it up easily later). Then I tried a few more things (that I can't really remember), and also this : http://stackoverflow.com/questions/38103244/building-boost-1-61-0-with-mingw-5-3-0 – Neox Jan 23 '17 at 02:40
  • That's not my idea of "precise". I appreciate you spent a lot of time. However, that does not make us psychics – sehe Jan 23 '17 at 02:42
  • @sehe I don't really know how to be more precise, what would you like to know? And to be honest I think the problem comes from me compiling the libs with the manually downloaded mingw, which probably has a different version than code blocks' one. But this was all right on my old computer... – Neox Jan 23 '17 at 02:55

1 Answers1

0

I found the solution, I'm posting it just in case it can help someone else.

The problem was because I had MinGW manually downloaded and I used it to compile the libs, and I was compiling my program with Code Blocks' MinGW. They probably had different versions, which was indeed the problem.

Neox
  • 279
  • 3
  • 13