2

I need to download Fortran to complete my project. I have tried following the video on youtube (https://www.youtube.com/watch?v=HakTEhU3Q9U) but I get an error right at the end. I can't compile a simple 'hello_world' program.

I am new to programming so I am not familiar with computing terminology. I have downloaded java, Eclipse, and Fortran. When I open Eclipse and I try to compile a simple program I get an error.

make all 
Building file: ../helloFortran.f95
/bin/sh: gfortran: command not found
Invoking: GNU Fortran Compiler
gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "helloFortran.o" "../helloFortran.f95"
make: *** [helloFortran.o] Error 127
"make all" terminated with exit code 2. Build might be incomplete.

17:00:47 Build Failed. 2 errors, 0 warnings. (took 94ms)

The program I am trying to run is simply this.

    program helloFortran
    implicit none
    print*, "Fortran is great"
end program helloFortran

I also have a text file which I do not know what it is for.

#!/bin/bash
PATH=$PATH:/usr/local/gfortran/bin
$HOME/eclipse/parallel-2018-12/Eclipse.app/Contents/MacOS/
eclipse -data $HOME/documents/workspace

Andy
  • 109
  • 1
  • 3
  • 14

1 Answers1

1

Make sure that the file EclipseFortran.sh containing

#!/bin/bash
PATH=$PATH:/usr/local/gfortran/bin $HOME/eclipse/parallel-2018-12/Eclipse.app/Contents/MacOS/eclipse -data $HOME/documents/workspace

The PATH line is a single line, up to workspace. Then, type

bash EclipseFortran.sh

and this should launch eclipse with knowledge of gfortran's location.

This is a bit unusual to setup the environment in this way. You can define environment variables on Mac OS for GUI applications. I am not using Mac OS so I can suggest to look at https://stackoverflow.com/a/3756674/3327666

launchctl setenv PATH $PATH:/usr/local/gfortran/bin
Pierre de Buyl
  • 7,074
  • 2
  • 16
  • 22
  • Im not sure when this changed but launchctl path was different for me. It is now: launchctl setenv PATH $PATH:/usr/local/bin/gfortran – CodeGuyRoss Apr 20 '20 at 17:24
  • It should be `launchctl setenv PATH $PATH:/usr/local/bin/` then. The PATH variable goes to the directory containing the executable programs, not to the executable file. – Pierre de Buyl Apr 21 '20 at 08:44