This question appears to be addressed properly in several questions and other places easily found with Google, but I don't find the solution satisfactory for the reasons explained below. But just for completion, I've included some relevant links:
https://askubuntu.com/questions/138284/how-to-downgrade-a-package-via-apt-get https://askubuntu.com/questions/428772/how-to-install-specific-version-of-some-package/428778 https://askubuntu.com/questions/26498/choose-gcc-and-g-version ...
However, this question is regarding installing a very specific version of GCC in Kali Linux, which does not appear readily available as a specific package. In particular, the question is regarding how to install version 6.3.0, as I need this version to compile a particular program: https://www.reddit.com/r/Monero/comments/6d0ah8/xmrig_miner_new_release/
(as a bonus question, if there is a more sane way to fix this particular issue without using a different version of GCC, feel free to answer, but I believe this question is general and I would like to know how to do it regardless of how to make the aforementioned program link correctly)
The versions which are available to install of any package, e.g. gcc, can be determined with:
apt-cache showpkg gcc
Which will list the available versions under "versions:", e.g.
Installation is then as simple as issuing
apt-get install gcc:4:4.9.2-2
This will install the older version 4:4.9.2-2, by simply (I believe) overwriting the 7.2.0-1d1 install, if present.
To get version 4:4.9.2-2 available at all, I had to add
http://old.kali.org/kali sana main non-free contrib to my
/etc/apt/sources.list file and then run
However, what if the version I need is not listed?
I've been experimenting with various sources, e.g. those found here: http://snapshot.debian.org/ and at various other questions and websites from Google searches.
Most of them give me ignore or errors, e.g. as follows
Ign:3 http://snapshot.debian.org/archive/debian/20091004T111800Z lenny InRelease
Even if this would work, it seems to be a very bad approach to get a particular version installed, as adding some arbitrary source might not have the particular version I want.
If I search on snapshot.debian.org for gcc, I get only very old versions: http://snapshot.debian.org/package/gcc/
I eventually became frustrated with this approach and compiled GCC 6.3.0 from the source tarball. The compilation was successful, but then I'm faced with how to install it. I'm cautious about running
make install as I fear it will tamper with
dpkg and possibly break the system.
Instead, I attempted to run it from the build directory, directly. I tried to simply add the build directory as the first entry in my PATH, which didn't work. Then, I attempted to rename
/usr/bin/gcc and do a symlink from
/usr/bin/gcc to where my gcc-6.3.0 executable lives. This presents the following problem:
cc: error trying to exec 'cc1': execvp: No such file or directory, which
This was fixed with another entry in my PATH.
Then, I get this error:
/usr/include/stdio.h:34:21: fatal error: stddef.h: No such file or directory
Which I assume is because of a missing entry in
/usr/lib/gcc/x86_64-linux-gnu. I tried to make a symlink from 6 to 6.3.0, but this wasn't sufficient. I also tried to actually copy everything with
cp -R, same result.
This should be a 64-bit program, but I also considered the same for
I'm sure I could start doing
strace to see where it attempts to open the files from, read log files, read the source, and eventually I imagine I'd be able to figure out how to hack together a poorly conceived solution. But it would be nice if someone could tell me how to do this in a sane manner.