gfortran在Mac OS X 10.9(Mavericks)上不起作用
最近,我将OS X更新为10.9(小牛);不幸的是,尽管我将OS X Mavericks的Xcode命令行更新为5.1.1,但gfortran停止工作.不久前,有人在此处提出了类似的问题,但我认为问题没有得到解决.
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.
这是我所做的:
首先,我删除了现有的gfortran
first I removed the existing gfortran
bash-3.2$ sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran
然后我下载了gfortran-4.9-bin.tar,并将其解压缩并成功安装
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.
仅作记录.我建议从此处提供的软件包中安装gfortran:
Just for the record. I suggest to install gfortran from packages that are available from here:
https://gcc.gnu.org/wiki/GFortran
macOS安装程序可以在这里找到: http://coudert.name/software/gfortran-6.3-Sierra.dmg
macOS installer can be found here: http://coudert.name/software/gfortran-6.3-Sierra.dmg
只需安装最新版本(使用dmg文件),一切就可以了
Just install most recent release (using dmg file) and everything should be fine
! fort_sample.f90
program main
write (*,*) 'Hello'
stop
end
编译和执行顺利
> gfortran -o fort_sample fort_sample.f90
> ./fort_sample
Hello