How Do I change the Environmental Variables for OpenMPI?
Look in your home directory's .profile to see how to add things to your PATH.
Where you installed the openmpi probably has subdirectories named bin, lib64, etc. For example, $HOME/openMPI is where you selected to install it, so add $HOME/openMPI/bin to your PATH at the end of your .profile:
export PATH="$HOME/openMPI/bin:$PATH"
Then add the line:"
export LD_LIBRARY_PATH=$HOME/openMPI/lib64
(assuming you have no existing LD_LIBRARY_PATH.)
Now that you have a location ...openMPI/bin early in your PATH, you can override the standard system commands by putting new ones there, like a
link named gcc to the gcc-8.4 version (which is available in 20.04). If you needed a version of gcc not available in the standard packages, you could simply put the entire executable (from wherever you get it) in place of the link.
Maybe you prefer not to override gcc every time you login. In that case, just set up a script to run instead of putting the changes into your .profile.
The usual gotchas:
- Your login does not really create a login shell, so .profile is not executed (Usually not an Ubuntu problem, but all the suggestions for putting PATH mods into .bashrc stem from this issue.
- You made a .bash_profile which overrides the .profile -- well you should know if you did that, and modify .bash_profile instead.
- Suggestions to modify /etc/alternatives to change system default gcc will basically cranch your system the next time you update and need the standard, released, tested compiler.
Your path addition probably should start with a /, so /home/openmpi/... rather than just openmpi/... However, look in the openmpi directory, and see if there is a bin directory, that is the one I expect if there are actually openmpi executables to run. Into that one you can add the gcc link to the lower level gcc...bin just to keep all the openmpi programs together. Note that the gcc 8.4 is available as a standard package in Ubuntu 20.04, but if your openmpi install has one, it's OK to use it, it just won't get any updates, if any.