I tried install on my Debian strench g++-4.9 and I didn't find package via
apt-cache search g++-4.9
Oldest version I found only g++-5
Where can I get g++-4.9?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
This works for debian10.3 without any package conflicts.
It downloads packages directly from the Debian FTP server and then installs them through dpkg.
#!/bin/bash set -xe BASE_URL=http://ftp.us.debian.org/debian/pool/main/ PACKAGES=$(cat <<-END g/gcc-4.9/cpp-4.9_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/g%2B%2B-4.9_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/gcc-4.9-base_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/gcc-4.9_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/libgcc-4.9-dev_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/libasan1_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/libubsan0_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/libcilkrts5_4.9.2-10%2Bdeb8u1_amd64.deb g/gcc-4.9/libstdc%2B%2B-4.9-dev_4.9.2-10%2Bdeb8u1_amd64.deb m/mpfr4/libmpfr4_3.1.5-1_amd64.deb c/cloog/libcloog-isl4_0.18.4-1+b1_amd64.deb i/isl/libisl10_0.12.2-2_amd64.deb i/isl/libisl15_0.18-1_amd64.deb END ) mkdir -p ./downloads/gcc4.9 cd ./downloads/gcc4.9 while IFS= read -r package; do wget -c $BASE_URL$package done <<< "$PACKAGES" sudo apt-get install multiarch-support sudo dpkg -i ./*.deb
I got it working (very unsoundly) by adding jessie repo and then installing from it. Include in /etc/apt/sources.list:
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free
Do apt-get update && apt-get install g++-4.9
After installation comment out jessie lines so that it doesn't conflict later with stretch. It would have been much better if Debian had included other g++ versions. Strangely enough, we have many versions of gcc bundled but only one version of g++ (6.0).
Note the following useful answer: https://askubuntu.com/a/428199/456089
Instead, simply download all these:
binutils_2.25-5_amd64.deb cpp_4.9.2-2_amd64.deb g++_4.9.2-2_amd64.deb gcc_4.9.2-2_amd64.deb gcc-4.9-base_4.9.2-10_amd64.deb libasan1_4.9.2-10_amd64.deb libatomic1_4.9.2-10_amd64.deb libcilkrts5_4.9.2-10_amd64.deb libgcc1_4.9.2-10_amd64.deb libgcc-4.9-dev_4.9.2-10_amd64.deb libgomp1_4.9.2-10_amd64.deb libitm1_4.9.2-10_amd64.deb liblsan0_4.9.2-10_amd64.deb libmpfr4_3.1.2-2_amd64.deb libquadmath0_4.9.2-10_amd64.deb libstdc++-4.9-dev_4.9.2-10_amd64.deb libstdc++6 libtsan0_4.9.2-10_amd64.deb libubsan0_4.9.2-10_amd64.deb
From Debian's servers, e.g.:
Then install them, e.g.: $ for package in *.deb; do sudo dpkg --install "$package"; done
Note that you might hit some issues with dependencies, so you want to use as few of the packages in that list as you can get away with.