undefined reference to `__gnu_cxx::__exchange_and_add(int*, int)’

  c++, gcc, gcc4, linux, sles

I am trying to build C++ code using GCC 4.3.4 on SLES-15 and getting below error.

/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: /lib/libc.so.6:
(IND+0x0): multiple definition of __umoddi3
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: /lib/libc.so.6:
(IND+0x0): multiple definition of __udivdi3
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: LicenseFile.o: in function `remove_dots(char const*)’:

LicenseFile.cpp:(.text+0x16a8): undefined reference to `__gnu_cxx::__exchange_and_add(int*, int)’

I believe these both error a linked to same root cause, as same works on SLES-11 with GCC 4.3.4.

The default gcc version on SLES-15 is gcc 7 and I have installed gcc 4.3.4 and created softlink for g++-4.3.4 and gcc-4.3.4 as g++ and gcc respectively.

Source: Windows Questions C++