|home| |posts| |projects| |cv| |bookmarks| |github|

Cross Execution With Qemu

If you want to test a binary on a particular architecture, but you don't have a machine with that architecture(e.g. mips), you can use qemu to simulate that architecture.

Here's how.

Install qemu-user-static

On ubuntu:

apt install qemu-user-static

Run your program

First you need your binary compiled for that architecture.

To obtain it, see previous post about cross-compilation. Or, if you use Go, use the GOARCH variable to compile your program for the wanted architecture.

I'll use here the binaries from the previous post and assume the native machine is a x86_64one.

Run on mips:

qemu-mips-static example-mips
hello

Run on aarch64:

qemu-aarch64-static example-aarch64
hello