# linux environment variables doubt

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

## Recommended Posts

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 #### Share this post ##### Link to post ##### Share on other sites Advertisement 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? #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by bytecoderProbably 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 #### Share this post ##### Link to post ##### Share on other sites 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. #### Share this post ##### Link to post ##### Share on other sites$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.

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
631775
• Total Posts
3002278
×