「gdbk を使って ゲームボーイプログラムで hello.c Ubuntu 版」
https://qiita.com/nanbuwks/items/53c0323341edfe10c58f
では Ubuntu でプログラム作成を試していましたが、MS-Windowsで同様に gdbk を試してみます。
環境
- MS-Windows11 Pro 25H2
- mGBA インストール済み (GBA エミュレータ)
cf.,「mGBA を MS-Windows で使ってみる」
https://qiita.com/nanbuwks/items/3b6a28d6ff972dacf1d0
ダウンロード
https://github.com/gbdk-2020/gbdk-2020/releases

から、gbdk-win64.zip をダウンロード。
インストール
解凍。解凍した場所が開発環境の動作フォルダとなります。動作フォルダはドライブCでなくてなおかつ、スペースを含むフォルダだと問題が起こるようです。
コマンドプロンプトから解凍したディレクトリに移ります。
>cd Downloads\gbdk-win64
>cd gbdk
>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 60D1-2FC6 です
C:\Users\admin\Downloads\gbdk-win64\gbdk のディレクトリ
2025/10/22 19:40 <DIR> .
2025/10/22 19:40 <DIR> ..
2025/10/22 19:40 392,841 asmlnk_manual.txt
2025/10/22 19:40 <DIR> bin
2025/10/22 19:40 29,818 ChangeLog
2025/10/22 19:40 <DIR> examples
2025/10/22 19:40 1,745,608 gbdk_manual.pdf
2025/10/22 19:40 <DIR> include
2025/10/22 19:40 <DIR> lib
2025/10/22 19:40 <DIR> libexec
2025/10/22 19:40 <DIR> licenses
2025/10/22 19:40 3,012 README
2025/10/22 19:40 1,116,951 sdccman.pdf
5 個のファイル 3,288,230 バイト
8 個のディレクトリ 125,720,211,456 バイトの空き領域
サンプルプログラムをコンパイルするには?
>cd examples
>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 60D1-2FC6 です
C:\Users\admin\Downloads\gbdk-win64\gbdk\examples のディレクトリ
2025/10/22 19:40 <DIR> .
2025/10/22 19:40 <DIR> ..
2025/10/22 19:40 130 compile.bat
2025/10/22 19:40 <DIR> cross-platform
2025/10/22 19:40 <DIR> gb
2025/10/22 19:40 485 Makefile
2025/10/22 19:40 <DIR> megaduck
2025/10/22 19:40 <DIR> msxdos
2025/10/22 19:40 <DIR> nes
2025/10/22 19:40 <DIR> sms
2 個のファイル 615 バイト
8 個のディレクトリ 125,720,211,456 バイトの空き領域
ここで間違えて compile.bat を動かしてみましたが、途中でエラーで止まってしまいました。
>compile
コンパイルできてなかった gb/sound に移り、
>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 60D1-2FC6 です
C:\Users\admin\Downloads\gbdk-win64\gbdk\examples\gb\sound のディレクトリ
2025/10/22 19:40 <DIR> .
2025/10/22 19:40 <DIR> ..
2025/10/22 19:40 178 compile.bat
2025/10/22 19:40 981 Makefile
2025/10/22 19:40 463 readme.md
2025/10/22 19:40 29,744 sound.c
4 個のファイル 31,366 バイト
2 個のディレクトリ 125,693,739,008 バイトの空き領域
ここでコンパイルしてみます。
>compile.bat
sound.gb ができたのでダブルクリックすると実行できました。
hello.c
examples\gb\template_minimal を元にして、 hello プログラムを作ってみます。
template_minimal\main.c は以下のようになっていました。
#include <gb/gb.h>
#include <stdint.h>
void main(void)
{
// Loop forever
while(1) {
// Game main loop processing goes here
// Done processing, yield CPU and wait for start of next frame
vsync();
}
}
これを参考にして、以下のような hello.c を作成しました。
#include <gb/gb.h>
#include <stdint.h>
#include <stdio.h>
void main(void)
{
printf("Hello");
}
gbdkディレクトリ中に、app\test\helloフォルダを作り、先の hello.c を保存します。
テンプレートの compile.bat は以下のようになっていたので
>type ..\template_minimal\compile.bat
REM Automatically generated from Makefile
..\..\..\bin\lcc -o Example.gb main.c
コマンドで以下のようにしてコンパイルしました。
>..\..\..\bin\lcc -o hello.gb hello.c
hello.gb ができました。ダブルクリックすると mGBA から実行できました。

