LoginSignup
2
2

More than 1 year has passed since last update.

【M1 Mac】Visual Studio CodeでC++ & Boostライブラリを使用する

Posted at

概要

M1 MacでAtCoder用のVisual Studio Code & C++のローカル環境を構築する際, C++で多倍長整数を扱いたい時に必要なBoostライブラリのインストールとVisual Studio Codeの設定とコンパイルで詰まったのでメモ.

インストール

自分は, CUI & GUIアプリをできるだけHomebrewで管理したいので, Homebrewでインストール.
Homebrewわからんという人は別記事を参照してください.

brew install boost

Boostがどこにあるのか

ここです.
バージョンは人によって違うかと思います.

/opt/homebrew/Cellar/boost/1.80.0/include

(自分の場合)ホームディレクトリからルートディレクトリまでの構造は以下なので, cd ../を2回してルートディレクトリへ遷移.

hogehoge
    |- Users
        |- /

VSCodeの設定

.vscode/c_cpp_properties.jsonincludePathに先ほどのBoostのパスを追記.
これで, VSCode側がBoostを認識します.

"includePath": ["/opt/homebrew/Cellar/boost/1.80.0/include"],

コンパイル

コンパイルオプションに先ほどのBoostのパスを指定.

g++ hogehoge.cpp -I /opt/homebrew/Cellar/boost/1.80.0/include
2
2
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
2
2