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?

DevBoxを使ってMacOSでAtomVMをビルド・実行する

Last updated at Posted at 2026-01-21

はじめに

この記事では、DevBoxを使ってMacOS上にAtomVMの開発環境を構築し、Erlang/ElixirのHello Worldを動かすまでの手順を紹介する。

AtomVMとは

AtomVMは、マイクロコントローラ向けに設計された最小限のErlang VM。ESP32、STM32、Raspberry Pi Picoなどの組み込みデバイスでErlang/Elixirを動かすことができる。

環境構築

前提条件

  • macOS (Apple Silicon)

DevBoxのインストール

curl -fsSL https://get.jetify.com/devbox | bash

ソースコード取得

git clone https://github.com/atomvm/AtomVM.git
cd AtomVM

devbox.jsonの作成

AtomVMリポジトリにはdevbox.jsonが含まれていないため、リポジトリのルートディレクトリで手動で作成する。

devbox init
devbox add cmake@latest gperf@latest github:NixOS/nixpkgs/31cab29#zlib.dev mbedtls@latest erlang@latest rebar3@latest github:NixOS/nixpkgs/31cab29#elixir

作成されるdevbox.json:

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json",
  "packages": [
    "cmake@latest",
    "gperf@latest",
    "github:NixOS/nixpkgs/31cab29#zlib.dev",
    "mbedtls@latest",
    "erlang@latest",
    "rebar3@latest",
    "github:NixOS/nixpkgs/31cab29#elixir"
  ]
}

一部パッケージはNix Flakeで固定リビジョンを指定している:

  • zlib: zlib@latestではなくgithub:NixOS/nixpkgs/31cab29#zlib.devを使用。開発用ヘッダー(zlib.h)を含むパッケージが必要なため。
  • Elixir: elixir@latestではなくgithub:NixOS/nixpkgs/31cab29#elixirを使用。DevBoxのElixirプラグインにバグがあるため。詳細はこちらのPRを参照。

ビルド

DevBox環境に入る

devbox shell

初回は依存パッケージのダウンロードに時間がかかる。

ビルド実行

リポジトリのルートディレクトリで以下を実行する。

cmake .
make -j 8

-j 8はCPUコア数に応じて調整可能。

ビルド確認

ls -la ./src/AtomVM

AtomVMバイナリが生成されていれば成功。

動作確認

./src/AtomVM ./examples/elixir/HelloWorld.avm

Elixir HelloWorld実行結果

トラブルシューティング

ZLIBが見つからないエラー

Could NOT find ZLIB (missing: ZLIB_INCLUDE_DIR)

zlib@latestではなくgithub:NixOS/nixpkgs/31cab29#zlib.devを使用する。zlib@latestにはヘッダーファイル(zlib.h)が含まれていない。

Elixirのビルドエラー

Elixirパッケージの互換性問題が発生する場合は、devbox.jsonのElixirリビジョンを確認。elixir@latestではなく、固定リビジョン(github:NixOS/nixpkgs/31cab29#elixir)を使用すること。

まとめ

DevBoxを使うことで、AtomVMのビルドに必要な依存関係を簡単にセットアップできた。

参考

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?