1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VSCodeで競プロ環境構築(gccインストール)(mac)[2021/03/27]

Last updated at Posted at 2021-07-19

最初に

Qiitaのこちらの記事を参考にして、gccのインストールをしようとしたのですがgccのバージョンが変わっていて、手こずったのでまとめておこうと思う。
https://qiita.com/EngTks/items/ffa2a7b4d264e7a052c6
 

はじめに

上記の記事に従って、VScodeの拡張機能のインストールやhomebrewのインストールなど、「gccのインストール、pathの設定」以外は済ませておく。

gccのインストール

% brew install gcc

インストール後、/usr/local/下に、g++-10がある。10という数字はバージョンごとに違うので、人により異なります。現在の最新バージョンは10です。

(ちなみに、/usr/local/にいくにはfinderを開いて、メニューバーの「移動」から「フォルダへ移動」を選択して「/usr/local/」を入力。隠しフォルダなので普通には見れません。)

pathの設定

インストールが終わると、mac上に2種のコンパイラ(clang, gcc)が同居している状態になる。

/usr/bin/g++            #clang
/usr/local/bin/g++-10   #gccの実体

この状態でg++コマンドを打つと、/usr/bin/g++(clang) の方が呼び出される。

% which g++
/usr/bin/g++

pathを通すため、以下のシェルスクリプトを実行。

% ln -s /usr/local/bin/g++-10 /usr/local/bin/g++

このようにすることで、g++コマンドで/usr/local/bin/g++が呼び出されるようになった。

% which g++
/usr/local/bin/g++
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?