Advertisement

linux environment variables doubt

Started by July 02, 2006 03:52 PM
3 comments, last by Bregma 18 years, 4 months ago
Hi, I downloaded a fortran compiler (gfortran), and I wanted to make gfortran accessible everywhere so I edited .profile, adding: export PATH=$PATH:/path/to/gfortran/bin/ however, for gfortran to work it needs some libs, so I added: export PATH=$PATH:/path/to/gfortran/lib/ and it needed more stuff so I kept adding the folders to the file.... But there has to be a better way to do this... right? I tried something like: export PATH=$PATH:/path/to/gfortran/* but no luck... :( 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."
Probably the easiest thing to do, since it apparently requires a few dependencies, is to just copy the binaries and libraries into the /usr/local/bin and /usr/local/lib, respectively. I'm kind of confused why a binary package wouldn't do this in the first place. What format did you download it in?
Advertisement
Quote: Original post by bytecoder
Probably the easiest thing to do, since it apparently requires a few dependencies, is to just copy the binaries and libraries into the /usr/local/bin and /usr/local/lib, respectively. I'm kind of confused why a binary package wouldn't do this in the first place. What format did you download it in?


tar.bz2
"Through me the road to the city of desolation,Through me the road to sorrows diuturnal,Through me the road among the lost creation."
It's very likely that there's a package of gfortran for whatever distribution you're using. Use that. gfortran is part of the GCC, so every self-respecting distribution should have it.

As for the libraries: good luck. The GCC stuff has a rather greebly setup in that department. Adding libraries to the PATH variable won't help. You'll need to add the path to your /etc/ld.so.conf and run ldconfig afterwards. That might help.
$PATH is the wrong variable for anything except lanching executable programs.

To pick up libraries at compile time, you will need to instruct the link phase on where to find them (this is the same for all and every compiler on every platform, it is not unique to GCC). For this, you use the command-line switch -L. You can add this to you Makefile (or Makefile.am and configure.ac, depending on your desired level of build sophistication).

To pick up libraries at run time, you need to either instruct runtime loader (ld.so, via /etc/ld.so.conf) where to find the libraries, if they're shared libraries (.so files) or just set the environment variable $LD_LIBRARY_PATH using the colon-separated syntax like you used for $PATH.

There is no better way to customize your configuration. Either you put everything in a place the toolchain and runtime loader look by default, or you have to instruct them explicitly using some mechanism such as Makefiles or environment variables. This is as true for GCC/gfortran as it is for Visual Studio on Windows.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement