> For the complete documentation index, see [llms.txt](https://mwx.twelite.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mwx.twelite.info/v0.1.7/install_n_build/building-act/build-cmd-line.md).

# コマンドラインによるビルド

ツールを使う場合でも最終的にはコマンドラインで make を呼び出してビルドを実行しています。ここでは、コマンドラインでのビルド方法について記述します。

## ビルドスクリプト(Windows10)

{% hint style="warning" %}
macOS, Linux では[VS Code](/v0.1.7/install_n_build/building-act.md#vs-code-denobirudonitsuite)または[コマンドライン](/v0.1.7/install_n_build/building-act.md#komandorainlinuxmacoswskdenobirudo)によるビルドを行います。
{% endhint %}

ビルドスクリプトは、エラーがあまり出ることのない、完成済みのアクト、サンプル提供のアクトなどに向いています。

以下は **Windows10用のスクリプト（バッチファイル）**&#x3067;す。

| バッチファイル名       | 内容            |
| -------------- | ------------- |
| build-BLUE.cmd | TWELITE BLUE用 |
| build-RED.cmd  | TWELITE RED用  |

実行後にbinファイルが生成され`PingPong_BLUE_???.bin` または`PingPong_RED_???.bin` のファイル名になります。???はバージョン番号やライブラリのバージョン文字に置き換わります。

![PingPong アクトのディレクトリを開く](/files/-LwLMAIFEDxX9S1cck1H)

![build-BLUE.cmd をダブルクリック(実行)](/files/-LwLMVpnf2VXtOisvczY)

![ビルド結果](/files/-LwLLxtxWKFfzJb32xDq)

![BINファイル(PingPong\_BLUE\_L1203\_V0-1-0.bin) が出来ている](/files/-LwLMlA0GbTmwRBhOG26)

{% hint style="success" %}
BINファイルが出来上がればビルド成功です。
{% endhint %}

{% hint style="info" %}
`objs_BLUE`ディレクトリはビルド中に生成された中間ファイルです。削除してもかまいません。
{% endhint %}

{% hint style="warning" %}
ビルドを迅速にするためパラレルビルドのオプションを設定しています。このためエラーが出た場合はエラーメッセージを視認しづらくなっています。

エラーメッセージを効率的に参照したい場合は VS Code などの開発ツールの利用を推奨します。
{% endhint %}

### クリーン（中間ファイルの削除）

`build-clean.cmd`を実行すれば、`objs_` で始まるディレクトリを消去します。BINファイルは消去しません。

{% hint style="warning" %}
ビルドがうまくいかない場合は、まずエラーメッセージを確認して下さい。errorという文字列が含まれる行中のメッセージから、エラー原因が容易に特定できる場合も少なくありません。

`objs_???` ディレクトリにある中間ファイルを削除してから再実行してみてください。（他の環境でビルドした中間ファイルが残っていると`make clean`を含めすべての操作が失敗します)
{% endhint %}

## コマンドライン(Linux/macOS)でのビルド

コマンドライン環境でのビルドについて補足します。

{% hint style="warning" %}
コマンドライン(bash)についての利用の知識が必要です。
{% endhint %}

{% hint style="danger" %}
OS環境によっては各実行プログラムの動作時にセキュリティ警告が出る場合があります。警告を抑制する設定が必要になります。（**警告を抑制してプログラムを動作する運用を行うか**は、お客自身またはシステム管理者に相談の上、ご判断ください）
{% endhint %}

コマンドラインでのビルドは、bash(Bourne-again shell)が動作するウインドウで`make`を実行します。事前に環境変数`MWSDK_ROOT`が正しく設定されていることを確認してください。例えば`C:/MWSDK`にインストールした場合は `~/.profile` に以下のような設定を行います。

```bash
MWSDK_ROOT=/mnt/c/MWSDK
export MWSDK_ROOT
```

コマンドライン(bash)よりmakeを実行します。`make`がない場合はパッケージをインストールする必要があります。

```bash
$ make

Command 'make' not found, but can be installed with:

sudo apt install make
sudo apt install make-guile

$ sudo apt install make
...
```

{% hint style="info" %}

* Linux/WSL環境では`make`または`build-essential`パッケージをインストールします。
* macOS環境ではXcodeでCommand Line Toolsをインストールします。
  {% endhint %}

ビルドは以下のようになります。

```
$ cd $MWSDK_ROOT
$ cd Act_samples/PingPong/build
$ pwd
/mnt/c/MWSDK/Act_samples/PingPong/build

$ ls
... ファイル一覧の表示

$ rm -rfv objs_*
... 念のため中間ファイルを削除

$ make TWELITE=BLUE
... BLUE用に通常ビルド

$ make -j8 TWELITE=BLUE
... BLUE用にパラレルビルド(同時に8プロセス)
```

### 中間ファイルについて

ビルドが行われると objs\_??? ディレクトリが作成され、その中に中間ファイルが生成されます。このファイルはコンパイルした環境に依存しているため、他の環境のファイルが残っているとmakeがエラーとなりビルドが失敗します。

{% hint style="warning" %}
makeがエラーとなった場合は**直接`objs_???`ディレクトリ**を削除してください。
{% endhint %}

### コマンド例

詳細は[Makefileの解説](/v0.1.7/install_n_build/makefile.md)をご覧ください。

| コマンド例               | 解説                |
| ------------------- | ----------------- |
| `make TWELITE=BLUE` | TWELITE BLUE用にビルド |
| `make TWELITE=RED`  | TWELITE RED用にビルド  |
| `make cleanall`     | 中間ファイルの削除         |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mwx.twelite.info/v0.1.7/install_n_build/building-act/build-cmd-line.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
