Build Qemu on OSX

概览:

Qemu

Download Source code

1
2
wget https://download.qemu.org/qemu-5.0.0.tar.xz
tar -zxvf https://download.qemu.org/qemu-5.0.0.tar.xz

Get Dependence

1
brew install libtool pkg-config glib gnutls libpng libssh libusb lzo ncurses nettle pixman snappy vde libffi jpeg

Build

1
2
cd qemu-5.0.0
./configure --target-list=x86_64-softmmu,aarch64-softmmu --cc=/usr/bin/clang --host-cc=/usr/bin/clang --cpu=x86_64 --prefix=/Users/mardan/workspace/qemu --disable-bsd-user --disable-guest-agent --enable-curses --enable-vde --extra-cflags=-DNCURSES_WIDECHAR=1 --enable-cocoa --disable-sdl --disable-gtk

Explain:

  • –target-list : CPU Architecture
  • –cc : Compiler Name
  • –host-cc : Enable localhost Compiler
  • –cpu : Optimization for Native
  • –prefix : make install path
  • –disable,–enable : Modify Featuer
1
2
make -j9
make install

Check

Now you can check this(prefix) path:

On me like this

1
2
3
4
5
6
7
8
9
10
$ pwd
/Users/mardan/workspace/qemu
$ ls
bin share include
$ ls bin
elf2dmp qemu-img qemu-nbd qemu-system-aarch64
qemu-edid qemu-io qemu-storage-daemon qemu-system-x86_64
$ qemu-system-x86_64 --version
QEMU emulator version 5.0.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

Issues

  • Q
1
2
3
ERROR: User requested feature curses
configure was not able to find it.
Install ncurses devel
  • A
1
export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"

Reference

https://github.com/Homebrew/homebrew-core/blob/master/Formula/qemu.rb

https://wiki.qemu.org/Hosts/Mac