You can't easily convert an x86 binary to ARM. If you can't get the source code, or an ARM binary from the manufacturer, and you really do want to use the printer with your Pi2, then the Qemu approach is the correct one in this case, although it will likely be very slow. Qemu does full system emulation but it also works very well for single process emulation.
I'm assuming you have some sort of Debian derivative on your Pi2 (I'm not sure this will work with Raspbian though), and that the binary you have is for i386
(if it's 64-bit, use amd64
instead). Start by adding i386
as a foreign architecture:
sudo dpkg --add-architecture i386
sudo apt-get update
Then run ldd
on the binary and add any required libraries; typically
sudo apt-get install libc6:i386
and anything else with the :i386
suffix added. Make sure this doesn't remove any installed package; hopefully everything you need is multiarch-enabled. (Otherwise the rest won't work.)
Once you've done that, install qemu-user-static
if it isn't already installed (along with its binfmt-support
recommendation); then you can use qemu-i386-static
to run your program:
qemu-i386-static /usr/lib/cups/filter/rasterorp3150
In fact thanks to binfmt-support
it should run directly (as pointed out by Toby Speight):
/usr/lib/cups/filter/rasterorp3150
(binfmt-support
will use Qemu to make this work transparently.)
If you don't want to use binfmt-support
, move rasterorp3150
away:
sudo mv /usr/lib/cups/filter/rasterorp3150 /usr/lib/cups/filter/rasterorp3150.x86
and install a script containing
#!/bin/sh
exec qemu-i386-static /usr/lib/cups/filter/rasterorp3150.x86 "$@"
as /usr/lib/cups/filter/rasterorp3150
.
If you'd rather you can set up a chroot for all this; see debootstrap
and its --foreign
option (the chroot can be set up to use Qemu automatically).
Best Answer
Each architecture speaks its own hardware language so of course ARM CPUs can only run ARM binaries natively. If you want to run binaries for another architecture you need to use an emulator. The most famous x86-64 emulators are qemu and bochs
But emulation is extremely slow so it won't be suitable for time-sensitive applications, and should be the last resort. You'll better off recompile from source if available, or find an ARM alternative software