M1 Mac でのC言語実行環境構築

ちょっと必要があって手元のM1 Macbook ProC言語実行環境を整えたのだが、少々苦戦したので備忘録。

何度も「Command Line Tools」のインストールが求められていた件

既にインストールが完了しているにも関わらず、 gcc コマンドを叩く度にインストールを求められていたので、インストール場所を確認。

xcode-select -p
/Applications/Xcode.app/Contents/Developer

パスがオカシイようなので、以下のコマンドで場所を変更。

sudo xcode-select -switch /Library/Developer/CommandLineTools

Password:
※PCログインパスワードを入力

xcode-select -p
/Library/Developer/CommandLineTools

無事に gcc が実行できるようになった。

gcc --version
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin