0

On MacOS terminal, when I run this command:

$ which clang

I got:

clang version 10.0.0
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Users/myusername/anaconda3/bin

But,I have another clang version on my Mac, the directory is:

/Library/Developer/CommandLineTools/usr/bin/clang

So, how to change my current clang directory (/Users/myusername/anaconda3/bin) to a new clang directory (/Library/Developer/CommandLineTools/usr/bin/clang)?

and I am wondering that why my clang is defaulted to install in Anaconda?

zy zhao
  • 3
  • 3

2 Answers2

0

You should install the brew command on macOS. https://brew.sh/

It's better to use it to install clang because the command line tools version of clang's outdated.

0

export PATH=/Library/Developer/CommandLineTools/usr/bin:$PATH should work. You could add it to your run config file, whichever shell you're using.

carce-bo
  • 480
  • 2
  • 10
  • Thanks. I have already added this line to ./zshrc as well as ./bash_profile. Then I got this: ` Apple clang version 14.0.0 (clang-1400.0.29.102) Target: x86_64-apple-darwin21.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin ` It works. But the final problem I want to solve with is : I can't use command 'clang' to compile my .cpp files. For example, 'clang hello.cpp -o hello', the result is: ` 'wchar.h' file not found #include_next ^~~~~~~~~ – zy zhao Oct 19 '22 at 10:41
  • Thanks. I have already added this line to ./zshrc as well as ./bash_profile. Then I got this:
    Apple clang version 14.0.0 (clang-1400.0.29.102)
    Target: x86_64-apple-darwin21.6.0
    Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    – zy zhao Oct 19 '22 at 10:49
  • you might find [this question](https://stackoverflow.com/questions/26185978/macos-wchar-h-file-not-found)'s answers useful for your case ? – carce-bo Oct 19 '22 at 10:51
  • Else just install clang through `brew` and update to latest version – carce-bo Oct 19 '22 at 10:51
  • should i uninstall my clang first? Seems that I have 3 versions of clang, it's terrible. – zy zhao Oct 19 '22 at 10:53
  • Yes, one version is enough haha – carce-bo Oct 19 '22 at 10:58