バックナンバーはこちら。
https://www.simulationroom999.com/blog/model-based-of-minimum-2-backnumber/
はじめに
前回はビルド環境(Visual Studio 2017 express、cmake)とソースコードの在り処(Github、zip)を確認した。
用意はできたので、
今回は、実際にFMILibraryのビルドを始める。
登場人物
博識フクロウのフクさん

イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん

イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
FMILibraryのビルド手順

一応、必要なものは揃ったと思うのだけど、
あとはどうすれば良いのかな?

簡単に手順を説明しよう。
①開発者コマンドプロンプトforVS 2017を起動。
②cmakeでビルド
③ライブラリのインストール

以上だ。

そんなにいろいろやるわけじゃないのね。
開発者コマンドプロンプトforVS 2017を起動

これはスタートメニューから起動すれば良いね。

そうそう。
Visual Studio 2017 → 「Visual Studio 2017 Tools コマンド プロンプトを開く」
を選べばOKだ。

うん。
確かにコマンドプロンプトが開いた。
cmakeでビルド

次はcmakeでビルドだけど、
何をどうすればよいんだ??

以下のコマンドを実行だね。
> cmake -DFMILIB_INSTALL_PREFIX=c:\fmilib2 -DFMILIB_FMI_PLATFORM=win64 -G "Visual Studio 15 2017 Win64" <ソースディレクトリ>\FMILibrary-2.0.3\

このコマンドの意味は??

-DFMILIB_INSTALL_PREFIX=c:\fmilib2
はインストールフォルダの指定だね。

そして
-DFMILIB_FMI_PLATFORM=win64
は扱うプラットフォームの指定。
今回はWindows10 64bit想定だ。

-G “Visual Studio 15 2017 Win64”
は作成するVisual Studioのversionとプラットフォームの指定。

-DはCMakeList.txtへの変数指定で
-Gはcmake自体に対する指示だな。

cmkae自体に対する指示?
CMakeList.txtには書かれていないパラメータってこと?
cmakeの-Gオプションについて

そうだね。
cmkaeのヘルプを見ると分かる。
一部だけ引用しよう。
Generators
The following generators are available on this platform (* marks default):
Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
Use -A option to specify architecture.
* Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".

ほー。
今回使うVisual Studio 2017で、Windowsの64bitOSだと、
“Visual Studio 15 2017 Win64”
ってことになるのか。
確かに今回指定している物と一緒だね。
まとめ

まとめだよ。
- FMILibraryのビルド手順を確認。
- 開発者コマンドプロンプト起動、cmakeでビルド、ライブラリインストール。
- cmakeへのオプションがちょっとややこしい。
- FMILIB_INSTALL_PREFIXでインストール先。
- FMILIB_FMI_PLATFORMでプラットフォーム。
- -Gでビルドする環境指定。
バックナンバーはこちら。
コメント