Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22052

boost.regex fails to link with MinGW and GCC compiler

$
0
0

On Windows 10 I installed MinGW, and use Eclipse to write C++ programs together with Boost libraries 1.71.0 (for example boost/algorithm/string.hpp). I can successfully create the executable using boost::replace_all(doc, "@", "_"); in my source code.

The compiler is GCC version 8.2.0

As I also want use the Boost.regex library I built the Boost libraries suffing following commands commands in a Command Prompt window

bootstrap.bat

.\b2 --prefix=C:\Users\makkun\Documents\boost_1_71_0\build install 

I then changed to the Boost root directory and invoked b2 as follows:

b2 --build-dir=C:\Users\makkun\Documents\boost_1_71_0\build toolset=gcc --build-type=complete stage

The directory C:\Users\makkun\Documents\boost_1_71_0\stage\lib was created and I can see the regex related files

libboost_regex-mgw82-mt-d-x32-1_71.a
libboost_regex-mgw82-mt-d-x32-1_71.dll.a
libboost_regex-mgw82-mt-sd-x32-1_71.a
libboost_regex-mgw82-mt-s-x32-1_71.a
libboost_regex-mgw82-mt-x32-1_71.a
libboost_regex-mgw82-mt-x32-1_71.dll.a
libboost_regex-mgw82-mt-d-x32-1_71.dll
libboost_regex-mgw82-mt-x32-1_71.dll

In Eclipse I added in MinGW C++ Linker > Libraries > Library search path (-L) the library folder "C:\Users\makkun\Documents\boost_1_71_0\stage\lib"

In my source code I have

    #include <boost/regex.hpp>
    ...
    boost::regex e("(\\d{4}[- ]){3}\\d{4}");

The compilation is OK, but the linking with command

g++ "-LC:\\Users\\makkun\\Documents\\boost_1_71_0\\stage\\lib""-LC:\\Users\\makkun\\Documents\\boost_1_71_0\\libs" -o LastDoc.exe "src\\LastDoc.o"

fails with 46 errors of the type undefined reference to:

 c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: src\LastDoc.o: in function `ZN5boost16re_detail_10710027cpp_regex_traits_char_layerIcEC2ERKNS0_21cpp_regex_traits_baseIcEE':
    C:/Users/makkun/Documents/boost_1_71_0/boost/regex/v4/cpp_regex_traits.hpp:370: undefined reference to `boost::re_detail_107100::cpp_regex_traits_char_layer<char>::init()'
    c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: src\LastDoc.o: in function `ZN5boost16re_detail_10710011raw_storage6extendEj':
    C:/Users/makkun/Documents/boost_1_71_0/boost/regex/v4/regex_raw_buffer.hpp:131: undefined reference to `boost::re_detail_107100::raw_storage::resize(unsigned int)
...'

I also tried to add in MinGW C++ Linker > Libraries > Libraries (-l) string "boost-regex" but the linker does find it

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lboost_regex

Can anybody suggest where the problem is, please?


Viewing all articles
Browse latest Browse all 22052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>