ld: library not found for -lgcc

After a brew upgrade every time I try to compile a .c file I get the following error:

ld: library not found for -lgcc
collect2: error: ld returned 1 exit status

Wrappers like mpicc still work though. I tried relinking with brew link --overwrite gcc, but got no working results, as it is already linked. brew doctor doesn't give me a hint.


Solution 1:

I'm not sure with it's like this, but if I compile with gcc-4.9 (as the gcc version I have instaled is version 4.9.2) instead of gcc it works as it should. So the compilation sentence that seems to work is gcc-4.9 -o exec_name program.c. If someone knows why it is like this I would be interested to know.