问题
Recently, I updated my OS X to 10.9 (Mavericks); unfortunately, gfortran stops working although I updated Xcode command line to 5.1.1 for OS X Mavericks. Similar question has been asked sometime ago, here, but I don't think so the issue is sorted out.
here is what I did:
first I removed the existing gfortran
bash-3.2$ sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran
Then I downloaded gfortran-4.9-bin.tar, and unzip it and installed successfully
bash-3.2$ gunzip gfortran-4.9-bin.tar
bash-3.2$ sudo tar xvf gfortran-4.9-bin.tar -C /
bash-3.2$ which gfortran
/usr/local/bin/gfortran
but when I start running my codes , I got the following errors, e.g.
bash-3.2$ gfortran boolean1.f90
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
I would be immensely grateful if anyone could guide me to solve this problem.
回答1:
Just for the record. I suggest to install gfortran from packages that are available from here:
https://gcc.gnu.org/wiki/GFortran
macOS installer can be found here: http://coudert.name/software/gfortran-6.3-Sierra.dmg
Just install most recent release (using dmg file) and everything should be fine
! fort_sample.f90
program main
write (*,*) 'Hello'
stop
end
Compilation and execution goes smooth
> gfortran -o fort_sample fort_sample.f90
> ./fort_sample
Hello
来源:https://stackoverflow.com/questions/23501128/gfortran-is-not-working-on-mac-os-x-10-9-mavericks