Jump to content
  • Advertisement
Sign in to follow this  
FreJa

linux environment variables

This topic is 4344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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 .

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!