Advertisement

linux environment variables

Started by July 02, 2006 11:39 AM
5 comments, last by Fruny 18 years, 4 months ago
Hi, I downloaded the binaries for the gcc fortran compiler. However, I want to be able to access this compiler anywhere in the terminal (not only where the executable is)... i think this has something to do with setting environment variables...? Any help? Huge thanks
"Through me the road to the city of desolation,Through me the road to sorrows diuturnal,Through me the road among the lost creation."
Is this a local copy that you installed in your home directory or a global install? If it's the former, you can set the PATH variable in ~/.bashrc to include the directory where the binary is:
export PATH=$HOME/path/to/gcc:$PATH

Note: make sure the path points to the directory where the binary is, whether or not it's the toplevel gcc(fortran) directory.

If you installed it globally it should already be accessible in either /usr/bin or /usr/local/bin .

edit:
Also, if you modify .bashrc and don't want to reopen a terminal for it to take effect, you can just do source ~/.bashrc .
Advertisement
Oftentimes, a new user's path will already include ~/bin . This is the standard place to put an individual user's binaries (as opposed to ones everyone on the system uses).
---New infokeeps brain running;must gas up!
iw onder why you "downloaded the gcc fortran binarys" ... isnt he in the source tree?

and why dont you download a package instead of the binarys? ... you wouldnt have thees kinda problems if you did
Hmm, I just noticed this was in general programming. In case you have any more questions, you can always stop by the Everything Unix forum.
The other way to do this sort of thing is to write a wrapper script that would sit in your PATH and would call the actual binary. Something like

#!/bin/bash/path/to/binary/g77 $*


This also gives you the flexibility of running multiple versions side-by-side as you can do

#!/bin/bash/path/to/binary/${FORTRAN_VERSION}/g77 $*


Then in your .bash_rc you can "export FORTRAN_VERSION=whatever" and the script will resolve the version for you at runtime
Advertisement
Quote: Original post by bytecoder
Hmm, I just noticed this was in general programming. In case you have any more questions, you can always stop by the Everything Unix forum.



Moved appropriately.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement