require cc 9.4.0,current /usr/bin/cc 11.4.0 does not match
Assistant
If you require cc version 9.4.0 but your current version is 11.4.0, you will need to install the older version of the compiler and configure your system to use it. Here's a way to achieve this on a Unix-like system:
1. Check for available GCC versions:
First, check if the required GCC version is already available in your package manager's repositories.
For Ubuntu/Debian:
sudo apt-cache policy gcc-9
For Fedora:
dnf list gcc
2. Install the required GCC version:
If it's available, you can install it. For Ubuntu/Debian, you can do this:
sudo apt-get install gcc-9 g++-9
For Fedora:
sudo dnf install gcc-9 g++-9
If the required version is not available through your package manager, you may need to download and install it from source or from an alternative repository.
3. Update alternatives to use the required GCC version:
Most Unix-like systems have a mechanism to manage multiple versions of a program. For example, on Debian-based systems, you can use the update-alternatives command to switch between different gcc versions.
You'll be given a menu to select the desired version.
4. Verify the version:
Finally, verify that the correct version is being used:
gcc --version
It should output information about gcc 9.4.0.
5. Alternative Approach: Docker
If you do not want to change the compiler on your entire system, another approach is to use a Docker container with the required compiler version.
Create a Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install -y gcc-9 g++-9
# Set gcc and g++ to version 9
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90
CMD ["gcc", "--version"]
Build and run the container:
docker build -t gcc-9-container .
docker run gcc-9-container
This will create an isolated environment with the required GCC version.
Summary
Depending on your needs, you can either switch the system's compiler version using update-alternatives or use a Docker container for an isolated environment with the required version.