Install WinUSB on Ubuntu 16.04 LTS

 Posted by:   Posted on:   Updated on:  2023-01-07T21:29:34Z

How to compile and install WinUSB on Ubuntu 16.04 LTS using wxWidgets 3.0.

WinUSB is probably the only GUI tool that allows you to create bootable USB drives with Windows from Linux. It hasn't been updated for a long time and there are no packages for newer Ubuntu versions. Until the release of 16.04, WinUSB could be installed from existing DEB packages for previous Ubuntu releases. But things have changed with the update of wxWidgets to version 3.0 in the default repositories. WinUSB GUI depends on wxWidgets > 2.8.4 and all curent builds are based on 2.8 releases of the library.

Let's mention again that WinUSB can't make UEFI bootable drives! Only the old MBR type and only NTFS formatted.

This guide has also been tested on Ubuntu 16.10. If you're using an older version of Ubuntu you may get WinUSB working by following this guide. Otherwise, you need to compile it with wxWidgets 3.0. This article will describe the procedure plus the extra tweaks you must make to ensure WinUSB works as it should.

Install WinUSB in Ubuntu 16.04 LTS

The first thing you will need is a source archive of WinUSB. Grab one from the nearest mirror. To make things easier, I made a script that will patch the obsolete code and compile WinUSB.

#!/bin/bash

sudo apt-get install gcc build-essential libwxbase3.0-dev libwxgtk3.0-dev
tar zxf winusb-1.0.11.tar.gz
cd winusb-1.0.11/src
sed -i -- 's#wxStandardPaths().GetInstallPrefix()#wxStandardPaths::Get().GetInstallPrefix()#g' findFile.cpp
sed -i -- 's#wxStandardPaths().GetDataDir()#wxStandardPaths::Get().GetDataDir()#g' findFile.cpp
cd ..
./configure
make
sudo make install
cd ..
rm -rf winusb-1.0.11

Save this into a text file with .sh extension, make it executable and run it in the same folder with the source archive you downloaded. It will install required build libraries and tools the compile the source.

Some things have changed with wxWidgets 3.0 and objects of class wxStandardPaths cannot be created anymore. Instead, a global wxStandardPaths object can be returned via wxStandardPaths::Get() call. Therefore all occurrences of wxStandardPaths(). must be replaced with wxStandardPaths::Get(). and this is what the script does using sed.

After you run this script, WinUSB will be installed and it should pop-up when you launch it. In order to make it work on UEFI systems, you have to:

a) install MBR dependencies for GRUB: sudo apt-get install grub-pc-bin

b) fix the GRUB installation method - open /usr/bin/winusb with a text editor with administrator rights (i.e. gksu gedit /usr/local/bin/winusb), find a line that starts with grub-install (line 401) and replace it with:

grub-install --target=i386-pc --boot-directory="$partitionMountPath/boot" "$device"

This is also described at the end of the previous article about installing WinUSB in Ubuntu 15.10.

You can't get it to compile? Drop a comment.

No comments :