1

I've been trying to install GCC 9.5 on Debian Bookworm (12) using gcc-12 which is available in the Debian repos. The build fails at make citing it couldn't find GLIBCXX_3.4.30. The relevant part of the make log is as follows:

Making all in po
make[5]: Entering directory '/home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/po'                                    
msgfmt -o de.mo ../../../../gcc-releases-gcc-9.5.0/libstdc++-v3/po/de.po                                                               
msgfmt -o fr.mo ../../../../gcc-releases-gcc-9.5.0/libstdc++-v3/po/fr.po
msgfmt: /home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version `GLIBCXX_3.4.30' not found
 (required by /lib/x86_64-linux-gnu/libicuuc.so.72)                
make[5]: *** [Makefile:550: de.mo] Error 1                         
make[5]: *** Waiting for unfinished jobs....                       
msgfmt: /home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version `GLIBCXX_3.4.30' not found
 (required by /lib/x86_64-linux-gnu/libicuuc.so.72)                
make[5]: *** [Makefile:550: fr.mo] Error 1
make[5]: Leaving directory '/home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/po'
make[4]: *** [Makefile:562: all-recursive] Error 1
make[4]: Leaving directory '/home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3'
make[3]: *** [Makefile:487: all] Error 2
make[3]: Leaving directory '/home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3'
make[2]: *** [Makefile:19557: all-stage1-target-libstdc++-v3] Error 2
make[2]: Leaving directory '/home/apps/builds/gcc/gcc-9/build'
make[1]: *** [Makefile:27270: stage1-bubble] Error 2
make[1]: Leaving directory '/home/apps/builds/gcc/gcc-9/build'
make: *** [Makefile:1002: all] Error 2

I used the following configure options:

configure --prefix=path-to-install-dir --disable-multilib --enable-languages=c,c++,fortran --enable-checking --program-suffix=9.5

I don't really understand the error I'm getting. The funny thing is, I can compile GCC 12 from source successfully in the same machine. The GCC source code is in /home/apps/builds/gcc/gcc-9/gcc-releases-gcc-9.5 while I'm building it in /home/apps/builds/gcc/gcc-9/build. The most recent version of GLIBCXX in /home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 is GLIBCXX_3.4.28

RogUE
  • 197
  • You might have more luck trying to build gcc9 with gcc10, which is available in the default Debian repos. – ajgringo619 Sep 10 '23 at 20:10
  • The error indicates that the library /home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 doesn't have the needed GLIBCXX_3.4.30 capabilities. Add the output of strings -d /home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 | grep -i glibcxx to the question. To be sure, is /home/apps/build/gcc the location of the source code? – Nasir Riley Sep 11 '23 at 01:00
  • @NasirRiley The source code resides in /home/apps/builds/gcc/gcc-9/gcc-releases-gcc-9.5.0 and I'm building it in '/home/apps/builds/gcc/gcc-9/build'. – RogUE Sep 11 '23 at 06:00
  • @NasirRiley /home/apps/builds/gcc/gcc-9/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6' is in the build directory and it doesn't haveGLIBCXX_3.4.30(it has glibcxx uptoGLIBCXX_3.4.28`). – RogUE Sep 11 '23 at 06:03
  • @ajgringo619 Is it not recommenced to build a previous release of GCC with a newer GCC? – RogUE Sep 11 '23 at 06:08
  • Add that information to the question by editing it. Don't post it in the comments where it can get lost. – Nasir Riley Sep 11 '23 at 11:37
  • See this question and answer for a sane approach to solving this. – eyoung100 Jan 26 '24 at 17:34

2 Answers2

1

The issue here is that your build ends up relying on system libraries which depend on a recent version of libstdc++.so.6, but builds an older version of libstdc++.so.6 itself. The latter is used in preference to the former, even when running third-party tools such as msgfmt (which is what fails in your example).

So the problem isn’t strictly speaking the compiler being used for the build, it’s the libraries which were used when building the new compiler’s dependencies... You might be able to work around this by skipping the libstdc++ build: add --disable-libstdcxx to the configure options. According to configure this produces a working configuration, but I haven’t run the build to check; in particular, I don’t know whether the “missing” libstdc++ would cause issues, or if the system libstdc++ would be used instead.

You might find it simpler to use the gcc-9 package in unstable — it provides all the libraries built correctly. You can access it using a container image or a chroot (see mmdebstrap).

Stephen Kitt
  • 434,908
  • Would disabling libstdc++ cause any problem down the road? I need this GCC build for building several other libraries which are themselves dependencies of several other programs. I do not want to end up with errors in those builds by disabling libstdc++ now. Is there a proper way to fix this issue rather than skipping libstdc++ build? – RogUE Sep 11 '23 at 16:59
  • See the updated answer. I don’t think there is a “proper” way of doing this, but you can look at the gcc-9 packaging in Debian unstable to see how it’s handled there... – Stephen Kitt Sep 12 '23 at 05:20
1

In order to build GCC which ships its own version of libstdc++.so.6, you first need to build a version of GNU gettext which is written in pure C, such as 0.17.

When configuring, supply a different prefix, such as /opt/gettext:

./configure --prefix=/opt/gettext

and temporarily add ${prefix}/bin to the PATH when building GCC.

Bass
  • 259
  • 4
  • 11