1

I've looked at other questions similar to mine for answers, but I still have no idea what I'm doing. I'm not new to Macs or working in terminal environments, but when it comes to computer structure I'm a novice.

I need to be able to compile Fortran codes on my computer. Cool, I'll install one of those: gcc. I have installed homebrew, updated my OS, updated XCode, and installed gcc. Still I cannot get gcc/gfortran to compile properly because there is some kind of broken link:

conamara:~ me$ brew link gcc
Linking /usr/local/Cellar/gcc/9.2.0...
Error: Could not symlink include/c++/9.2.0
/usr/local/include/c++ is not writable.

I tried changing the permissions with chmod but I ran up against an Apple/Mac OS wall. I've Googled this error and the solution was to disable SIP on Mac. I did that. It still did not work. I enabled SIP again since then so my (organizationally owned) computer isn't a security issue.

Someone told me last week all I had to do was unlink clang, the default on Mac OS. But there are multiple answers even on here for how to do that that range from creating aliases to changing paths. In theory I get what everything is supposed to do but I have no idea where to start fixing it.

Anyway, any and all help is appreciated and I'll try to give as many clarifying details as needed. Thanks much!

1 Answer 1

0

The owner of the /usr/local/include/c++ seems to be changed, which indicates you may used sudo with command brew. Never use sudo brew.

Firstly, fix the ownership recursively.

sudo chown -R "$USER":admin /usr/local/*

Secondly, relink the package gcc.

brew unlink gcc
brew link --overwrite gcc

References

1
  • Yup, I did use sudo brew not knowing what it would damage. A little knowledge is worse than none sometimes. Your fix worked, thank you so much! Commented Sep 26, 2019 at 16:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .