【GameBoy模拟器 1】在macOS上编译启动

先跑个马里奥再说

项目介绍

这是一个基于C语言的GameBoy模拟器,使用CMake进行项目构建,有完整的代码仓库与视频教程。

相关链接

项目意义

  • 作为游戏玩家和人类,实现童年梦想,满足好奇心和创造欲
  • 作为计算机专业学生,在用代码模拟硬件的过程中,能够了解CPU、RAM、ROM、GPU、BUS、IO、Interrupt等计算机体系结构中的重要概念
  • 作为求职者/从业者,在项目实操过程中,能够熟悉相关工具链、锻炼工程能力、提高解决问题能力

macOS编译启动流程

原始项目与ubuntu系统进行开发,作者附有windows启动教程,笔者习惯使用macOS,因此尝试了在macOS进行编译启动,也是成功的。笔者以5个游戏镜像实测,此模拟器成功运行了其中的一个:SuperMarioLand。以下为macOS编译启动的具体教程:

How to use on macOS

Deploy Env

  • Machine: MacBook Air m1
  • OS: macOS 14.2
  • Compiler: Apple clang version 15.0.0 (clang-1500.1.0.2.5) from Apple’s default CommandLineTools
  • Other requirements: Homebrew 4.2.0

setup:

  1. clone the repo to your local directory
1
2
3
git clone https://github.com/SimpleCodeJust4Fun/cBoy.git
cd LLD_GEBEMU
cd part16
  1. use cmake to construct the project
1
2
3
4
mkdir build
cd build
cmake ..
make

install the essesntial libraries with homebrew if cmake or make is not successful:

1
2
3
brew install sdl2
brew install sdl2_ttf
brew install check

remember to delete the cmake cache before you start cmake or make again

1
rm -rf *
  1. run the emulator
1
2
cd gbemu
./gbemu <rom_file>

key modification that enable success build on mac

  • add include_directories("/opt/homebrew/include") in CMakeLists.txt

explaination:

  • the dependencies sdl2, sdl2_ttf and check are installed with homebrew, the original repo was desined to run on Linux and Windows therefore did not add homebrew include path in CMakeLists.txt
Licensed under CC BY-NC-SA 4.0
最后更新于 Jun 25, 2025 15:02 UTC
Built with Hugo
Jimmy 设计的 Stack 主题