gcc error: terminate called after throwing an instance of ‘std::regex_error‘ what(): regex

created at 02-05-2022 views: 26

problem

The reason for this error should be a problem with the gcc version.

View version command:

gcc --version

If nothing else, it should be the version of 4.8.x

After querying gcc4.9, c++ regular expressions are supported, so we need to upgrade gcc.

First find a source package of gcc4.9 to install (find one yourself)

mkdir build
…/./configure
make & make install

Executing configure may report an error:

linux : error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

Note that these three libraries need to be installed:

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
  • tar.bz2 decompression command tar -jxvf
  • tar.gz decompression command tar -zxvf
./configure
make & make install

Executing configure of gmp may report an error:

error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons)

Indicates that the m4 library is missing

wget http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.bz2

Executing ./configure may report an error:

./stdio.h:477:1: error: 'gets' undeclared here (not in a function)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

Enter m4/lib to find a stdio.in.h problem, if you can't find it, you can try to use find -name stdio.in.h

comment out the first line

_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

add below

#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

Then compile these libraries all the way

When it comes time to compile gcc

configure reported an error again

I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler , rerun configure with --disable-multilib.

implement

sudo yum install glibc-devel.i686
sudo yum install libgcc.i686

Oh it's finally over Execute make && make install to go

Oh, forgot to mention, if your machine is multi-core, you can perform parallel compilation make -j8 The number behind represents the number of cores

During this time, you can watch a movie, but after watching make without any accident, it has not finished executing. . . . .

I feel that it is not the language itself that persuades newbee, but the environment configuration under linux.

created at:02-05-2022
edited at: 02-05-2022: