问题
I was following an online tutorial to install some Python modules using homebrew and one step was to install gfortran with brew install gfortran
. Later on, I tried using another third-party installation script to install some Python modules and after the fact I realized that part of what the script did was download and run http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg. I don't know that much about gfortran, but looking at the brew formula for gfortran it appears that brew uses a different version from the att.com one. Will that lead to problems in the future? I did brew uninstall gfortran
and brew install gfortran
again, and so far it seems like things are the same (I tried recompiling the old code that I had compiled before), but I am not sure what all the att.com pkg did. (I have OS X 10.8.2 and XCode 4.2 if that matters).
回答1:
It depends on where the other gfortran installer goes to. In general, no, it won't conflict. * Homebrew is designed to be compatible with third-party gfortran
installs - it defines dependencies on a generic "fortran" compiler, and not on the specific gfortran
Homebrew formula. Homebrew stays under /usr/local, sticking the main install in /usr/local/Cellar, and symlinking judiciously in to /usr/local/lib. Other installers that install to /usr/local will just prevent Homebrew from linking its own compiler in, but will work with other formulas that use a fortran compiler. (Assuming the gfortran
build options are compatible.)
That particular gcc-42 installer you linked to installs to /usr
, not to /usr/local
.** And its binaries are suffixed with "-4.2"; that is, it installs cpp-4.2
, g++-4.2
, gfortran-4.2
, and so on. So a) there's no direct conflict with the Homebrew gfortran, and b) it won't directly shadow the /usr/local/bin/gfortran
installed by Homebrew.
Which compiler will get picked up by things you build with both these gfortrans installed will depend on how the build works, but most will be looking for plain gfortran
and so will find the Homebrew one, unless you explicitly direct them to the AT&T-provided one. You don't specify how you're building things, but since you're using brew, I'm assuming it's via brew
or command line tools, in which case I think they're all probably seeing the Homebrew gfortran and ignoring this one. Look at the verbose output from their build processes to find out for sure.
*Depending, of course on what you mean by "conflict".
**Side note: AFAIK there's no easy way to figure this out by looking at the package or an installation manager. I just did a find /usr
before and after running that installer, and did a diff
on the output:
$ diff usr_before_any_installs.txt usr_after_att_install.txt | grep '^[<>]'
> /usr/bin/c++-4.2
> /usr/bin/cpp-4.2
> /usr/bin/g++-4.2
> /usr/bin/gcc-4.2
> /usr/bin/gfortran-4.2
> /usr/bin/i686-apple-darwin11-cpp-4.2.1
> /usr/bin/i686-apple-darwin11-g++-4.2.1
> /usr/bin/i686-apple-darwin11-gcc-4.2.1
> /usr/bin/i686-apple-darwin11-gfortran-4.2.1
> /usr/include/gcc
> /usr/include/gcc/darwin
> /usr/include/gcc/darwin/4.2
...
来源:https://stackoverflow.com/questions/14222930/does-installing-gfortran-with-homebrew-and-with-an-installer-create-a-conflict