Linking Compiler in Terminal

Discussion in 'Mac Programming' started by bonestruca, Jun 11, 2008.

  1. macrumors newbie

    Joined:
    Nov 16, 2007
    #1
    Hey,
    I downloaded g95, a fortran compiler as binary. I tried to link it via "ln -s PATH_TO_BINARY/BINARY /usr/bin/g95" but it doesn't work. "Command not found" and "which" g95 tells me there is no g95 in /usr/bin/ (or anywhere else). So i looked up in /usr/bin and actually there is a "g95" !?

    I linked it again, but this time without "-s" (although the compiler manual tells me to link it with "-s") and now the linking works but the compiler doesnt !?

    the binary itself without link works fine.
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Is g95 executable? Which will tell you what would be executed if you ran that command, but if it is not executable, even if it's in your path, it won't run. Make sure f951 is also in your path and executable.

    Also, were these binaries you downloaded statically linked against the gcc libraries? What about the g95 runtime library libf95.a? Do you have a copy of that that was precompiled?

    I've always had to build from source because we had to apply some patches to the runtime to fix a few things we've found, so I haven't dealt with a binary installation before.

    -Lee
     
  3. thread starter macrumors newbie

    Joined:
    Nov 16, 2007
    #3
    "Is g95 executable ?" - yes it is.
    I already compiled and built files using 95 by executing it directly. Thats why I don't think its a library issue. It works fine but its pretty inconvenient to go that long way and everytime type the directory the binary is located to compile sourcecode. (eg. /Applications/G95/G95_binary -o file file.f90 when it could be g95 -o file file.f90 as a regular command.)
     
  4. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    I can't say why the symlink didn't work, but you should be able to add /Applications/G95/ to your path to save you some typing if ln isn't doing what you'd hope. You can just add:
    export PATH=$PATH:/Applications/G95/
    to your .bash_profile.

    Otherwise... I'm not at my Mac at the moment, but I've never seen issues symlinking before.

    Try:
    sudo ln -s /Applications/G95/G95_binary /usr/bin/g95

    to see if the issue is creating a file in a root owned directory without privileges. If it's not that, I am at a loss.

    -Lee
     
  5. macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #5
    well, a cheap shot workaround would be to insert the following line in your ~/.bash_profile or ~/.bashrc file (assuming you're using bash....adjust accordingly for tcsh, etc)

    alias g95='/Applications/G95/G95_binary'
     
  6. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #6
    Hi

    It might be worth checking that your soft link is actually pointing to what you think it should be. You could for example do:-

    Code:
    ls -lL /usr/bin/g95
    
    Whenever I make soft links I usually use tab completion on the command line to make sure I've got the path right. I don't know if you've used it before but you just need to type the first few letters of a path and hit tab and the command line will either complete that part of the path or beep. If it beeps just type a few more letters and try again, or hit tab twice to see a list of possibilities.


    As an alternative, you could just move G95_binary into /usr/bin.

    b e n
     

Share This Page