본문 바로가기

Study/라즈베리파이 공부

[Raspberry Pi] Is it possible to run x86 or x86-64 binary on ARM machine like Raspberry Pi?

반응형

The Raspberry Pi is an amazing machine. We can easily install Ubuntu Linux on Raspberry Pi. I sometimes confuse Raspberry Pi and desktop PC(x86-64). At that time, I come up with idea. How about setup software development environment on my Raspberry Pi instead of X86 PC.

 

I installed some packages like Git, Docker for software engineers. I downloaded my source codes from Git. Then I tried to build docker image on Raspberry Pi. And I encountered error message.

 

[My docker script]

FROMT ubuntu:16.04

RUN apt-get update && apt-get install -y libc6-i386

 

[Actual Result]

Fetched 16.7 MB in 20s (808 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libc-i386
The command '/bin/sh -c apt-get update && apt-get install -y libc-i386' returned a non-zero code: 100

 

We are using some binaries for building job. Some binaries of them were built for 80386. So, I added libc-i386 package to my docker script. But, ubuntu for ARM does not support libc-i386 package. If you are using x86-64, you can execute x86 binary with libc-i386.

 

[Before installation libc-i386 on x86-64 machine]

$ file alfill
alfill: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.2.5, not stripped
$ ./alfill
bash: ./alfill: cannot execute binary file: Exec format error

I cannot execute the binary. Because my machine is x86-64 and binary is 80386.

 

[After installation libc-i386 on x86-64 machine

$ sudo apt-get install libc-i386
$ ./alfill
(It works)

After installation libc-i386, we can execute 80386 binary on x86-64 machine.

 

[Tring install libc-i386 on ARM64]

$ sudo apt-get install libc-i386
E: Unable to locate package libc-i386

But, we cannot install libc-i386 package on ARM. Because the instruction set of ARM CPU is different X86's one. (The X86 is CISC CPU. And The ARM is RISC CPU.)

 

Finally, we cannot execute x86 binary on Raspberry Pi. You had better make tool as script language like python. Then, you can use it on X86 and on ARM.

 

Thank you.

반응형