John Harris <
john.ha...@gmail.com> wrote:
> Here is the code:
>
> program hello
> print *,'Hello World!'
> end program hello
>
> Here is the results from the command line:
>
> JohnsMac:Fortran John$ gfortran HelloWorld.f95
> HelloWorld.f95:1:2:
>
> end program hellorld!'ramn
> 1
> Warning: Illegal preprocessor directive
> Undefined symbols for architecture x86_64:
> "_main", referenced from:
> implicit entry/start for main executable
> ld: symbol(s) not found for architecture x86_64
> collect2: error: ld returned 1 exit status
>
> By the way the #! line is called a shebang to tell where the compiler is
> located.
Ah, yes. It's been long enough that I forgot the term, but that does
sound familliar. I would not count on it working with Fortran for the
reasons mentioned before. I suppose it might happen to work for some
installations, but I wouldn't count on it (not to speak of the fact that
it is inherently non-portable as compilers are located in different
places on different systems).
Afraid I'm out of good ideas. I'd guess that the compiler isn't
installed correctly, or perhaps that it is not an appropriate compiler
build for your system. Do note that you also need an appropriate XCode
installed. Someone else might be able to offer more constructive advice
than I can.
I just now copied and ran your code on the iMac I'm posting this from,
and it ran fine. I'm also using gfortran 6.1, but I'm on OS X 10.10.5.
As an unrelated side note, I discourage using file extensions like .f95;
the usual convention on is that the file extension indicates the source
form (.f for the old fixed source form or .f90 for free source form). It
is unfortunate that the .f90 looks like it indicates a version of the
standard, which has encouraged people to use other extensions like .f95,
.f03, and I suppose also probably others. Some compilers accept those
extensions as being synonymous with .f90, but it is most portable to
just use .f90. That's clearly not related to your current problem,
though. (Gfortran 6.1 does appear to accept the .f95).