In this presentation we will learn how to manage multiple version of development tools inside a linux machine.
I have three different versions of clang
version :
- clang-12
- clang-14
- clang-15
three different versions of python
:
version :
- python-2.3
- python-3.8
Installed on my machine. I want to manage them effectively on my system, considering that many scripts and makefiles rely on the clang
or python
keywords within their scripts and specify a specific version of the language.
Now, the question is: How can I use and compile a codebase that specifically requires the clang
keyword in its script and supports a particular version like clang-15
for compilation?
I'm curious if you have any solutions or suggestions for this challenge :)
There are two solutions to this problem, with the first one being a rather silly approach:
-
Manually modifying the scripts or CMakeLists.txt files, replacing all occurrences of
clang
withclang-15
. However, this method is not recommended as it can be cumbersome and error-prone. -
Alternatively, you can use symbolic links in your system. By creating a symbolic link named
clang
that points to the desired version, you can ensure that the codebase using theclang
keyword will utilize the specific version(clang-15)
for compilation.
All versions of Clang, Python, or any other software can be installed in these paths:
# For python
/usr/local/bin/python-2.3
/usr/local/bin/python-3.8
# or
/usr/bin/python-2.3
/usr/bin/python-2.8
#for clang :
/user/local/bin/clang-12
/user/local/bin/clang-14
/user/local/bin/clang-15
# or
/usr/bin/clang-12
/usr/bin/clang-14
/usr/bin/clang-15
To link a specific version to a keyword like clang, python, cmake, or any other software, you can use symbolic link this below exmple :
# here we bind python keywork to python-3.8
sudo ln -s /usr/bin/python /usr/bin/python-3.8
# And
# here we bind clang keywork to clang-15
sudo ln -s /usr/bin/clang-15 /usr/bin/clang-15
Now you can run your make script without any problems and you do not need to mess up or edit the makefile script. To check if it works, you can use the command below :
python --version
# or
clang --version
:)