Installing wine on Jetson Nano

Sorry, I just noticed your message yesterday since I did not visit the forum for a while. I already gave you a link how to setup chroot in one of my previous messages and how to build and install qemu. But it may be difficult to follow and adapt commands to your needs if you are not very familiar with Linux and Ubuntu.

By the way, it does not make sense to run apt or apt-get without sudo when running as non-root user. It looks like you already installed qemu, but you used prebuild qemu from Ubuntu 18 - old qemu will not work neither for wine in chroot nor for Windows. So you may want to remove it.

I wrote below instructions specific for Jetson Nano. There is still a chance you can encounter unexpected errors, if so please let me know.

The commands below will use precompiled qemu 6.0.0 deb. If you prefer to compile it yourself, this is how I did it: Compile and install qemu 6.0.0 on Jetson Nano - Pastebin.com.

cd /tmp/ \
&& wget -c http://dragon.studio/2021/05/qemu-user-static_6.0.0_arm.deb http://dragon.studio/2021/05/qemu-binfmt-conf.sh http://dragon.studio/2021/05/qemu-debootstrap \
&& sudo chmod +x qemu-binfmt-conf.sh qemu-debootstrap \
&& sudo cp -a qemu-binfmt-conf.sh qemu-debootstrap /usr/local/bin/ \
&& sudo apt-get remove \*qemu\* \
&& sudo apt install ./qemu-user-static_6.0.0_arm.deb
&& sudo apt -y install binfmt-support debootstrap binutils ubuntu-dev-tools \
&& cd /usr/bin/ \
&& sudo rm -f qemu-*-static \
&& for exe in qemu-*; do sudo ln "$exe" "$exe-static"; done

If you choose to install precompiled deb, you do not need to mess with /etc/apt/sources.list and do not need build dependencies such as newer libssh, and getting apt build-dep to work will not be necessary too.

&& means that next command will run only if previous was successful. You need to copy and paste in the terminal above commands all at once. If an error happens (perhaps internet connection goes down and download fails, or something else), you can just copy and paste them all one more time to try again if the issue was temporary. The installed deb with qemu will have version “1:2.11+dfsg-1ubuntu7.36-1” which is not correct (actual version is 6.0.0) but it seems to be necessary to fake it otherwise mk-sbuild script below will uninstall the package and will replace with real “1:2.11+dfsg-1ubuntu7.36-1” version from Ubuntu repositories which will not work. Creating “-static” versions of installed binaries is also needed to satisfy the mk-sbuild script. If the block of commands above finished without errors, all of this should be already done.

To register binfmt run this (it is necessary to run non-native binaries with qemu):

sudo qemu-binfmt-conf.sh --qemu-path="/usr/bin" --qemu-suffix="-static"

After installing qemu, create amd64 chroot:

mkdir -p ~/ubuntu/build \
&& cd ~/ubuntu/build \
&& mk-sbuild --arch amd64 focal \
&& sudo cp -a /usr/bin/qemu-i386-static /var/lib/schroot/chroots/focal-amd64/usr/bin/

If at the end you see the following message:

***********************************************
* Before continuing, you MUST restart your    *
* session to gain "sbuild" group permissions! *
***********************************************

Then exit (or reboot), login and then run these commands again:

mkdir -p ~/ubuntu/build \
&& cd ~/ubuntu/build \
&& mk-sbuild --arch amd64 focal \
&& sudo cp -a /usr/bin/qemu-i386-static /var/lib/schroot/chroots/focal-amd64/usr/bin/

Please note that if you reboot, you need to run the following command first (before trying to use mk-sbuild or trying to login to amd64 chroot environment):

sudo qemu-binfmt-conf.sh --qemu-path="/usr/bin" --qemu-suffix="-static"

It is good idea to add the above line to your startup script (the startup script will need to run as root so you will not need sudo otherwise it will ask your password each time).

In /etc/schroot/default/fstab uncomment the line for /run:

sudo nano /etc/schroot/default/fstab    

Then find these lines:

#/run           /run            none    rw,bind         0       0
#/run/lock      /run/lock       none    rw,bind         0       0

And change them like this (by deleting # symbol):

/run           /run            none    rw,bind         0       0
/run/lock      /run/lock       none    rw,bind         0       0

Assuming you are using nano, press Ctrl+O to save and then Ctro+X to exit.

Finally, copy Xauthority:

sudo cp ~/.Xauthority /var/lib/schroot/chroots/focal-amd64/root/

This command can also be added to your startup script so you do not have to run it manually each time after reboot. In the startup script you will need to replace ~ with full path (for example, in my case it is /home/lissanro).

Now we are ready to login to amd64 chroot environment:

sudo schroot -c source:focal-amd64 --directory="/root" -u root /bin/bash

If this is successful, you can install wine (no sudo in commands below because we are running as root in chroot environment):

dpkg --add-architecture i386
apt update
apt install --install-recommends wget curl nano ssl-cert ca-certificates winbind software-properties-common wine64 wine32 wine

Note: wine-development and wine32-development packages in Ubuntu Focal are broken; wine and wine32 are older but they work correctly. Wget, curl and nano are not necessary, but they are useful tools to have if you will need to edit or download files in your chroot environment. Both ssl-cert and ca-certificates are needed if to download from HTTPS sites so it is good idea to install them too.

Now you can try to run winecfg:

DISPLAY=:0 winecfg

If it works, you may try to install and run your Windows application. If necessary, you can use wget to download it and then run installation. Please note OpenGL does not work in qemu. At least I was not able to run glxgears in amd64 chroot, not even after installing OpenGL libraries and using LIBGL_ALWAYS_SOFTWARE=1 for software rendering. Also, some applications may try to use “illegal instructions” which qemu does not support.

You may want to add export DISPLAY=:0 to /etc/profile (or /etc/zsh/zshenv if you are using fizsh or zsh instead of bash), then after logging in again to the chroot environment you will not have to set DISPLAY variable manually each time.

I tested the setup above and I was able to run winecfg and wine notepad. I also was able to install some windows application and run it.

In case using qemu with wine will not work for you, there are other options. For example, GitHub - ptitSeb/box86: Box86 - Linux Userspace x86 Emulator with a twist, targeted at ARM Linux devices can be used instead of qemu if OpenGL support in Wine is necessary. But setting it up is very different from setting up qemu.

Running Windows for ARM in qemu (Xubuntu 20.04 Focal Fossa L4T R32.3.1 - Custom Image for the Jetson Nano - #98 by marietto2008) is yet another option, it includes i386 and amd64 emulation (Windows on Arm: This is how well 64-bit emulation is working | TechRepublic). Only downside running Windows in qemu will eat some additional memory compared to running wine with qemu.