1

Is it possible to prevent MacOS to stop mapping gcc to clang?

i want to run a tool its dependency is with gcc and not for clang. So i installed gcc but since i typing in gcc -v i am getting the mapped version to clang

how to prevent this?

this is how am i getting

Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Catalina
  • 663
  • 5
  • 20
  • Adjust your PATH – Richard Barber Jan 29 '20 at 21:48
  • What do you mean? do you mean this: Configured with: --prefix=/ – Catalina Jan 29 '20 at 21:49
  • Are you sure that `gcc` is not just a symbolic link to clang? – emacs drives me nuts Jan 30 '20 at 12:03
  • How do i can know that? do you have any solution? – Catalina Jan 30 '20 at 15:47
  • You’ll need to say something like `export PATH=/usr/local/bin:$PATH` depending on where your binary or wrapper is located. – Richard Barber Jan 30 '20 at 23:05
  • which value should be instead of `$PATH`? – Catalina Jan 30 '20 at 23:50
  • that export command appends a directory to the front of PATH, so that is a string $PATH. Your desired executable would be in the `/usr/local/bin` directory. – Richard Barber Feb 03 '20 at 09:37
  • now lets say the directory has other things you dont want in PATH. Create a new dir `mkdir /usr/local/catalinasfolder` link to the tool you want to have be in PATH there `ln -s /usr/local/bin/gcc /usr/local/catalinasfolder/gcc` then export the dir to PATH `export PATH=/usr/local/catalinasfolder:$PATH` verify with `which gcc` – Richard Barber Feb 03 '20 at 09:45
  • @RichardBarber i cant do this: premission denied. But if i try like this `alias gcc='gcc-9'` it works but since i reopen the terminal it goes back to clang – Catalina Feb 05 '20 at 11:08
  • prepend `sudo` to commands needing higher permission level. – Richard Barber Feb 05 '20 at 14:40
  • Check these threads: https://stackoverflow.com/questions/64992467/mac-clang-installation-seems-to-override-gcc-install https://stackoverflow.com/questions/28970935/osx-replace-gcc-version-4-2-1-with-4-9-installed-via-homebrew – Norbert May 29 '23 at 11:26

0 Answers0