Windows10でmatplotlib-cppを使用するまでに必要なソフトウェアのインストール方法について説明します。
使用するソフトウェア
・Visual Studio 2019
・CMake 3.18.0
・Python 3.6.8(バージョン3.7以降も使用可)
・matplotlib-cpp(2021/2/15時点)
Visual Studio 2019のインストール
1、以下URLから無料版のVisual Studio 2019のインストーラをダウンロードします。
https://visualstudio.microsoft.com/ja/free-developer-offers/

2、インストーラを起動したら、「C++によるデスクトップ環境」にチェックを入れ、インストールを行います。

CMakeのインストール
1、以下URLからWindows版のCMake 3.18.0のインストーラ「cmake-3.18.0-rc4-win64-x64.msi」をダウンロードします。
バージョン3.18.0のダウンロードは、「Older Releases」から行えます。
https://cmake.org/download/

2、インストーラを起動したら、「Add CMake to the system PATH for all users」を選択してインストールを行います。

Pythonのインストール
1、以下URLからPython3.6.8の” Windows x86-64 executable installer”をダウンロードします。
https://www.python.org/downloads/release/python-368/

2、インストーラが起動したら、“Add Python 3.6 to PATH”にチェックを入れ、インストールを行います。

matplotlib-cppのインストール
1、以下URLからmatplotlib-cppをZIP形式でダウンロードします。
https://github.com/lava/matplotlib-cpp

2、”matplotlib-cpp-master.zip”を解凍したら、フォルダ名を”matplotlib-cpp-master”から”matplotlib-cpp”に変更します。
3、”matplotlib-cpp”フォルダをダウンロードフォルダから”C:\local”に移動します。
※ Cドライブ直下にlocalフォルダがない場合、新規作成します。
4、コマンドプロンプトで以下のコマンドを実行し、numpy, matplotlibをインストールします。
> python -m pip install numpy
> python -m pip install matplotlib
サンプルプログラムのビルド
“C:\local\matplotlib-cpp\contrib\WinBuild.cmd”を実行し、サンプルプログラムのビルドを行います。WinBuild.cmdはダブルクリックでも実行できますが、ビルドが終わると実行ウィンドウが閉じてしまいビルド結果の確認が行えないので、コマンドプロンプトでWinBuild.cmdを実行することを推奨します。
C:\Users\ユーザ名>cd C:\local\matplotlib-cpp\contrib
C:\local\matplotlib-cpp\contrib>WinBuild.cmd
ビルドが完了したら、”C:\local\matplotlib-cpp\examples\build\Release”に実行ファイルが生成されるので、どのようなプログラムか確認してみてください。
ビルドエラーの対処方法
ビルドエラーの対処方法は、コラム「matplotlib-cpp tips【Windows10でビルドに失敗!?】」を参照してください。
https://rtc-fukushima.jp/column/5396/