9

I have recently installed Ubuntu ARM on my M1 MacBook Air on a virtual machine (using Parallels), and unlike Windows ARM and macOS ARM, Ubuntu ARM does not seem to include a translation layer for x86 apps, which makes the system almost unusable as a lot of Linux software does not support ARM yet.

For example, I got this error while trying to install VSCode with Gdebi:

screenshot

I cannot believe there is no translation layer on Linux ARM yet, considering it is an open source OS which often makes developing those kind of things easier and faster than on other operating systems.

Is there a translation layer out there which I could install?

hippietrail
  • 422
  • 1
  • 3
  • 13
Adrian2895
  • 207
  • 1
  • 2
  • 2
  • 5
    "... considering it is an open source OS which often makes developing those kind of things easier and faster than on other operating systems" - why would you think that? Open source does nothing of the kind. It might, and if it does that's fortuitous. But as a general statement? No. (It is certainly _possible_ to develop this stuff for an open source OS. But "easier"? "faster"? "easier _and_ faster"? Not in general.) – davidbak Nov 19 '21 at 02:26
  • 6
    It's open source so we don't need an emulation layer for most software, we just rebuild from source. But since qemu and binfmt-misc already exist, the pieces are in place for transparent emulation, just like how x86 Linux machines can be set up to Windows executables can be run with WINE transparently. – Peter Cordes Nov 19 '21 at 05:30
  • 17
    `as many Linux software do not support ARM yet` - the **majority** of Linux software already support ARM since around 2002. The fact that almost all Linux software support ARM is what makes projects like Android and Raspberry Pi successful. – slebetman Nov 19 '21 at 09:37
  • 2
    VSCode has an ARM version. But, as someone who's been stuck with a Raspberry Pi 4 for the last weeks, I strongly advise you to forget about running VSCode on an ARM CPU. My experience has been below garbage with it. It takes 2 minutes to save a file to a network share, in which VSCode spends all it's time just reading the files and doing nothing else. I have **WAY** better results running Notepad++ on top of WineHQ on top of Box86 on my Raspberry Pi 4. I used PiApps to install WineHQ and just installed Notepad++ from the website. It works ... ok, without autocomplete. Alternatively, use geany. – Ismael Miguel Nov 19 '21 at 11:34
  • 9
    @IsmaelMiguel that probably has nothing to do with ARM and the reason is only, that the Raspberry Pi 4 has a quite slow CPU. I assume running VSCode on an much much more powerful M1 CPU works without issues. – Josef Nov 19 '21 at 11:56
  • @JosefsaysReinstateMonica That is a good point. I didn't notice that there was the MacOS-style UI around the Ubuntu OS. I should have noticed it before saying anything. However, when someone says "on an ARM chip", people will think like micro-computers and similars, not an Apple product. – Ismael Miguel Nov 19 '21 at 14:12
  • 1
    @IsmaelMiguel "micro-computers" occupies a much higher space in the size hierarchy than you might think, encompassing all desktop and laptop computers and a great many servers. Exactly the sort of devices that can run a programming IDE well. – Ben Voigt Nov 19 '21 at 18:02
  • @BenVoigt Yes, but I gave my opinion based on my "micro-computer". A 2020 Raspberry Pi 4 (no overclock). And VSCode is below garbage on my "micro-computer". It's effectively useless to the point that having a Windows program being translated from x86 to ARM is a lot faster than VSCode. – Ismael Miguel Nov 19 '21 at 23:45
  • 1
    @IsmaelMiguel VSCode is basically a browser which runs an IDE implemented in HTML and JavaScript. Of course it is slow. It was even [known for using a whole CPU core just to blink the cursor](https://github.com/microsoft/vscode/issues/22900) once. Its just that computers are so fast today, that people get away with implementing a slow IDE using web technology... But that is not in any way related to ARM or AMD64. VSCode is slow on AMD64 too, its just harder to get a slow AMD64 CPU today. But try VSCode on an Intel Atom... – Josef Nov 22 '21 at 09:56
  • @JosefsaysReinstateMonica In my case, it was using over 30% of the CPU to access the Samba share, and analyze the files in it (for whatever reason). And it would just keep analyzing them, over and over and over and over again. If I open it to edit files locally, without a workplace folder, it behaved quite acceptably. – Ismael Miguel Nov 24 '21 at 08:37

3 Answers3

19

Box86 and Box64 are emulators that can be used to run traditional x86 apps in ARM.

Here is how to install Box64, so that you will be able to run amd64 binaries in arm64 (note that you won't be able to install amd64 .deb files this way. .deb files are not designed like that. However, you may still be able to extract the binary from a .deb file and run it.). These instructions are based on this guide.

First, install git and the necessary compilers, download the source with git, and enter the source directory.

sudo apt install git build-essential cmake
git clone https://github.com/ptitSeb/box64.git
cd ~/box64

Now create a directory named build, and generate the makefile using cmake.

mkdir build
cd build
cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo

Now compile, with all the available cores.

make -j$(nproc)

Now install the compiled software

sudo make install

Now restart the systemd-binfmt service.

sudo systemctl restart systemd-binfmt

Finally, restart the computer.

Now, you should be able to run binaries compiled for the amd64 architecture.


However, native arm64 builds for VSCode are available at its official website, you don't need to emulate it.


many Linux software do not support ARM yet...

You seem to be misinformed. Since most of the software in the repositories are Free and Open source, they have already been compiled, and readily available for ARM. According to https://debian.pkgs.org/, the arm64 repository for Debian Sid has 62542 packages, whereas the amd64 repository has 63568 packages (as of 18th Nov, 2021). People usually use box64 to emulate proprietary software created for Windows.

Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185
  • I think it should be possible to combine box[64/86] with deb, by making use of `dpkg --add-architecture amd64` – Pelle Nov 19 '21 at 08:23
  • 1
    @Pelle I have not tried that. In case you have tested it, feel free to edit. – Archisman Panigrahi Nov 19 '21 at 08:23
  • @ArchismanPanigrahi I tried these installations on an ARM based VPS. After completing them and rebooting, I am able to run amd64 command line programs. However, I have a amd64 GUI application (developed and compiled in Lazarus) and it does not run. It gives some errors like `gtk_major_version not found`, `gtk_minor_version not found`, `gtk_marshal_VOID__POINTER_POINTER not found`, and `gtk_key_snooper_install(ver 0: gtk_key_snooper_install) not found`. I think this is mentioned in https://github.com/ptitSeb/box64 under **Notes about GTK programs** – FedKad Nov 19 '21 at 10:59
  • Is there a way to have native-like support for the `amd64` (x86_32) architecture on ARM systems, similarly to how we can have support for `i386` (x86_32) support on `amd64` (x86_64)? I want to be able to install any `amd64` package via the package manager, either via `sudo apt install` or via installing `.deb` files. – Aaron Franke Dec 18 '21 at 03:36
  • @AaronFranke Have a look at the comment by Pelle. – Archisman Panigrahi Dec 18 '21 at 07:56
  • Once I have Box64 installed, how do I install system libraries for `amd64`? I have tried both `sudo dpkg --add-architecture amd64` and modifying `/etc/apt/sources.list` with lines starting with `deb [arch=arm64,amd64] http://us.ports` but apt is not able to find amd64 packages. – Aaron Franke Aug 28 '22 at 04:09
5

Qemu user emulation provides a very nice way to seamlessly run programs from other architectures. I have no practical experience with graphical programs however, so there may be dragons that way.

It also integrates with apt/dpkg by registering a foreign architecture.

Pelle
  • 363
  • 1
  • 6
  • Generally works fine for X, since it's client-server at heart. – hobbs Nov 20 '21 at 03:08
  • Following this guide, I installed the Qemu packages, `update-binfmts --display` seems to work correctly, then I added the `amd64` architecture in dpkg, but `apt` can't find any packages. `apt update` says `E: Failed to fetch http://us.ports.ubuntu.com/ubuntu-ports/dists/impish/main/binary-amd64/Packages 404 Not Found [IP: 91.189.91.38 80]`. What are the full instructions? It seems that something is missing that is needed on top of the Debian instructions. – Aaron Franke Dec 18 '21 at 18:15
  • Ports.ubuntu.com does not contain amd64 packages, you'll need to add the regular Ubuntu repositories. – Pelle Dec 19 '21 at 19:40
0

I have ran into same issue on Ubuntu Server and got the following error:

-bash: /usr/bin/my-script: cannot execute binary file: Exec format error

I found a general solution for running x86-64 files on arm CPU. Running the following code fixed it:

sudo apt update
sudo apt install -y qemu-user-static binfmt-support
sudo dpkg --add-architecture amd64
sudo apt update
sudo apt install libc6:amd64

Source : https://www.kali.org/docs/arm/x86-on-arm/