# Install URSim in WSL2
###### tags: `UniversalRobots`
* Win 11
* Ubuntu 22.04
* URSim 5.15.1
# Win 11
## Step 1.
Install **WSL**.
https://learn.microsoft.com/windows/wsl/install
## Step 2.
Set version to **WSL2**.
`wsl --set-default-version 2`
## Step 3.
Control Panel->Programs->Turn Windows features on or off->selected **Windows Subsystem for Linux** and **Virtual Machine Platform**
控制台–>程式和功能–>開啟或關Windows功能–>勾選**Windows子系統Linux版**與**虛擬機器平台**
## Step 4.
Download **VcXsrv**.
https://sourceforge.net/projects/vcxsrv
## Step 5.
Install Ubuntu 22.04 LTS from windows store and update Ubuntu envirment in **Ubuntu terminal**.
`sudo apt-get update`
`sudo apt-get upgrade`
# Desktop GUI
## Step 1.
Open **Ubuntu terminal** and install **X Server**.
`sudo apt-get install x11-apps`
## Step 2.
cd to home.
`cd /home`
build **`.bash_login`** in home.
`nano ~/.bash_login`
```bash
export DISPLAY=$(hostname).local:0
export WAYLAND_DISPLAY=
startxfce4
```
Press **Ctrl+x** then press **y** to save.
After that, press **enter** to exit.
## Step 3.
Install xfce4 desktop and reboot Ubuntu.
`sudo apt-get install xfce4-terminal`
`sudo apt-get install xfce4`
`sudo reboot`
## Step 4.
Back to **Windows** and open **VcXsrv**(XLaunch).
Select **One large window** and set **Display number** to **0**.
In the third page, selected **Disable access control**.
## Step 5.
Turn on **X Server** in **Ubuntu terminal**.
`startxfce4`
# URSim
## Step 1.
Download URSim 5.15.1
https://www.universal-robots.com/download/software-ur20ur30/simulator-linux/offline-simulator-e-series-and-ur20ur30-ur-sim-for-linux-5151/
## Step 2.
cd to the location of the file and extract it **`URSim_Linux-5.15.1.126626.tar.gz`** in.
`cd ~`
`tar xvzf URSim_Linux-5.15.1.126626.tar.gz`
## Step 3.
Modify **`install.sh`** in **/ursim-5.15.1.126626**.
line 85:
`commonDependencies='libcurl3 libjava3d-* ttf-dejavu* fonts-ipafont fonts-baekmuk fonts-nanum fonts-arphic-uming fonts-arphic-ukai'`
to
`commonDependencies='libcurl4 libjava3d-* ttf-dejavu* fonts-ipafont fonts-baekmuk fonts-nanum fonts-arphic-uming fonts-arphic-ukai'`
line 95:
` sudo bash -c "apt-get -y install lib32gcc1 lib32stdc++6 libc6-i386 $commonDependencies && (echo '$packages' | xargs dpkg -i --force-overwrite)"`
to
` sudo bash -c "apt-get -y install lib32gcc-s1-amd64-cross lib32stdc++6 libc6-i386 $commonDependencies && (echo '$packages' | xargs dpkg -i --force-overwrite)"`
## Step 4.
cd to **/ursim-5.15.1.126626/ursim-dependencies** and extract the archive data **libxmlrpc-c-ur_1.33.14_amd64.deb**.
`ar x libxmlrpc-c-ur_1.33.14_amd64.deb`
## Step 5.
Create new directory **/extras-control** and extract the control archive **`control.tar.gz`** there.
`mkdir extras-control`
`tar -C extras-control -zxf control.tar.gz`
## Step 6.
Modify **`control`** in **/ursim-5.15.1.126626/ursim-dependencies/extras-control**.
line 7:
`Depends: lib32gcc1 (>= 1:4.1.1), lib32stdc++6 (>= 4.1.1), libc6-i386 (>= 2.3.4)`
to
`Depends: lib32gcc-s1-amd64-cross, lib32stdc++6 (>= 4.1.1), libc6-i386 (>= 2.3.4)`
## Step 7.
cd to **/ursim-5.15.1.126626/ursim-dependencies/extras-control** and pack it back up.
After that, move it to the outer directory.
`tar cfz control.tar.gz *`
`mv control.tar.gz ..`
## Step 8.
cd to **/ursim-5.15.1.126626/ursim-dependencies** and pack up the following files into a new archive data **`new_urtool3_amd64.deb`**.
After that, remove **`libxmlrpc-c-ur_1.33.14_amd64.deb`**.
`ar r new_urtool3_amd64.deb debian-binary control.tar.gz data.tar.gz`
`rm libxmlrpc-c-ur_1.33.14_amd64.deb`
## Step 9.
cd to **/ursim-5.15.1.126626** and run **`install.sh`**.
`./install.sh`
Activate the URSim.
`./start-ursim.sh`
# Exception
If run **`install.sh`** failed, install the following lib and archive datas manually.
## Step 1.
Install **`lib32gcc-s1-amd64-cross`**.
`sudo apt-get install -y lib32gcc-s1-amd64-cross`
Might get error here, enter the following command to install dependencies.
`apt --fix-broken install`
## Step 2.
install the archive datas in **/ursim-5.15.1.126626/ursim-dependencies**.
`sudo dpkg -i new_urtool3_amd64.deb`
`sudo dpkg -i libxmlrpc-c-dev-ur_1.33.14_amd64.deb`
`sudo dpkg -i curl-dev-ur_7.18.2-1_amd64.deb`
# Reference
* https://hackmd.io/@JYU/B1zmv1MCU#GUI%E6%A1%8C%E9%9D%A2%E9%85%8D%E7%BD%AE
* https://askubuntu.com/questions/1446783/startxcfe4-with-vcxsrv-doesnt-work
* https://forum.universal-robots.com/t/installing-ursim-on-ubuntu-22-04/23166/5
* https://stackoverflow.com/questions/73895565/e-package-lib32gcc1-has-no-installation-candidate