New to Linux here. Already had gcc 11 and 12 on my ubuntu but compiled gcc-14 using following command:
./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-14.1.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-14.1.0
then after make && make install
I added gcc-14 to my list of available compilers using update-alternatives:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.1.0/bin/gcc-14.1.0 14 --slave /usr/bin/g++ g++ /usr/local/gcc-14.1.0/bin/g++-14.1.0 --slave /usr/bin/gcov gcov /usr/local/gcc-14.1.0/bin/gcov-14.1.0
However when compiling cpp code that use c++23 features I get link error:
/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.31' not found
I guess the libstdc++.so here is the one used for gcc-12 or gcc-11. libstdc++.so is available for gcc-14 at /usr/local/gcc-14.1.0/lib64/libstdc++.so
Is there a way to specify that gcc-14 should always use is own libstdc++ ? (Without specifying static path to the libstdc++ to use at compile time inside my cmake script)
Fixed my problem by doing:
sudo apt remove gcc-11 gcc-12
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt upgrade
New package gcc-13-base
has been installed and everything is fine now.
N.B: Not specifying --prefix when compiling make GCC install correctly and totally elude this problem