如何用Homebrew gfortran替换HPC gfortran? [英] How do I replace my HPC gfortran with Homebrew gfortran?

查看:127
本文介绍了如何用Homebrew gfortran替换HPC gfortran?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的优胜美地系统上安装了Xcode(以及命令行工具)和gfrotran 来自HPC ,并且想要用自制软件替换 HPC的gfortran(因为我无法使用HPC gfortran构建Python软件包).

要实现此目的的步骤是什么?

我想确定

  1. HPC的gfortran不见了(我只想要一个Fortran),
  2. Apple的工具仍然有效(用于Xcode,Swift,OS X和iOS开发等)

当然

  1. 我有一个可以正常构建Python软件包的gfortran工作版本.

可以做到吗?例如,我看到Homebrew的gfortran已作为gcc的一部分打包了,所以看来我将得到两个gcc版本(我想避免)或一个不能在Xcode上很好地使用的版本.

完成1-3的步骤是什么?

解决方案

我最近解决了同样的问题.这就是我在Yosemite系统上运行它的方式.

有关自制软件和命令行工具编译器的一些信息:

  1. 通过自制程序获得的编译器将覆盖现有的 ,如果它在同一位置.如果您有从命令行工具获得的fortran编译器,则它不会受到影响.(自制软件会在执行任何操作之前警告您)

  2. 通过命令行工具获得的编译器的二进制文件位于/usr/bin中.

  3. 使用自酿程序获得的编译器(以及其他所有内容)存储在地窖中(/usr/local/Cellar) 并且可执行文件链接到目录/usr/local/bin.

该怎么办?

  1. 修改路径: 我只需要使用通过自制程序获得的编译器,因此将/usr/local/bin移到了$path的顶部,这可以确保在/usr/bin之前搜索/usr/local/bin目录.

  2. 使用别名: 您可以为每个编译器创建一个别名,以便您可以根据需要互换使用它们.要创建别名,您将必须修改shell-rc文件.在我的系统上,我使用tcsh,并为自制编译器创建别名,我会在〜/.cshrc文件中添加与此类似的内容.

    alias brewgfortran '/usr/local/bin/gfortran'
    

    此命令现在执行存储在我的地窖中并链接到/usr/local/bin/gfortran/

  3. 的自制gfortran-4.9可执行文件
  4. 如果您绝对要删除Apple编译器,则可以从/usr/bin/目录中完全删除它们.我认为这不是最好的主意.我向您展示了几种避免使用它们的方法,并且如果出于某种原因需要它们,您将是SOL.我不能说您需要的那些工具是否可以在没有它们的情况下工作,因为我从未使用过这些工具,但是我知道它将为您构建python软件包(对不起,希望对您有所帮助)

注意::如果您使用的外壳与我不同,则别名的语法会稍有不同(我认为),请使用google或man alias

I currently have Xcode (along with command line tools) and gfrotran from HPC installed on my Yosemite system, and would like to replace HPC's gfortran with Homebrew's (because I'm having trouble building Python packages with the HPC gfortran).

What are the steps to accomplish this?

I want to be sure that

  1. HPC's gfortran is gone (I just want one Fortran) and
  2. Apple's tools still work (for Xcode, Swift, OS X and iOS development, etc.)

and of course

  1. that I have a working version of gfortran that reliably builds Python packages.

Can this be done? I see for example that Homebrew's gfortran is now packaged as part of gcc, so it looks like I'll end up with two versions gcc (which I'd like to avoid) or one that doesn't play well with Xcode.

What are the steps to accomplish 1-3?

解决方案

I recently worked through this very same problem. This is how I got/have it working on my Yosemite system.

Some things about home-brew and the command line tools compilers:

  1. The compiler you get through home-brew will overwrite the existing one if it is in the same place. If you have a fortran compiler that you obtained from the command line tools then it will not be affected.(Home-brew will warn you about this before doing anything)

  2. The binaries for the compilers you get through the command line tools are in /usr/bin .

  3. The compilers (and anything else) you obtain using home-brew are stored in the cellar ( /usr/local/Cellar) and the executables are linked into the directory /usr/local/bin.

What to do?

  1. Modify the path: I only needed to use the compilers I got through home-brew so I moved /usr/local/bin to the top of my $path this ensures that the /usr/local/bin directory is searched before /usr/bin.

  2. Use aliases : You can create an alias for each compiler so that you can use them interchangeably as you wish. To create an alias you will have to modify your shell-rc file. On my system I use the tcsh, and to create an alias for the home-brew compiler I would add something similar to this to my ~/.cshrc file.

    alias brewgfortran '/usr/local/bin/gfortran'
    

    this now executes the home-brew gfortran-4.9 executable that is stored in my cellar and linked to /usr/local/bin/gfortran/

  3. IF you absolutely want rid of the apple compilers you can of course remove them from the /usr/bin/ directory completely. I don't think this is the best idea though. I have shown you a few ways to avoid using them and if you ever needed them for some reason you would be SOL. I cant say if those tools you need will work without them as I have never used any of those, however I know it will build python packages for you (sorry hope this still helps)

NOTE: If you are not using the same shell as me the syntax for the alias is a little different (I think) just google it or man alias

这篇关于如何用Homebrew gfortran替换HPC gfortran?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆