Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vheidari/aaa24e63d7cfb034aedc682a0eb065d1 to your computer and use it in GitHub Desktop.
Save vheidari/aaa24e63d7cfb034aedc682a0eb065d1 to your computer and use it in GitHub Desktop.
If you have any problem to manage multiple version of development tools on your machine I recommend read this little MD to end.

Handling multiple version of CMake , Clang, Python or etc on your Linux system by symbolic link

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:

  1. Manually modifying the scripts or CMakeLists.txt files, replacing all occurrences of clang with clang-15. However, this method is not recommended as it can be cumbersome and error-prone.

  2. 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 the clang 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

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment