FreeBSD Wine Configuration

Wine is free and open-source software that provides a compatibility layer, which allows users to run applications made for Microsoft windows on BSD and Linux distributions. Its name, “Wine”, is actually a backronym for “Wine Is Not an Emulator”. This is because Wine doesn’t really utilize any virtualization or emulation techniques to run applications.

This tutorial will illustrate how to install and configure Wine on FreeBSD 12.0.

Installing Wine on FreeBSD

We will use the FreeBSD ports repository to get the latest packages for Wine, both for stable and development versions. If you’re using the 32-bit version of FreeBSD, just put the commands below to install Wine stable:

$ pkg install wine

For Wine development (32 bit):

$ pkg install wine-devel

For Wine experimental (32 bit):

$ pkg install wine-staging

However, if you’re using the 64-bit version of FreeBSD, download the i386 packages for Wine that allows 32-bit packages to run on 64-bit operating systems.

For Wine stable (64 bit):

$ pkg install i386-wine

For Wine Development (64 bit):

$ pkg install i386-wine-devel

For wine experimental (64 bit):

$ pkg install i386-wine-staging

Building Wine with chroot

First, add all the relevant i386 files into the chroot folder.

To build Wine on FreeBSD, we’ll use chroot as follows:

$ cd /usr/src
$ make buildworld TARGET=i386
$ make installworld TARGET=i386 DESTDIR=/compat/i386
$ make distribution TARGET=i386 DESTDIR=/compat/i386
$ mkdir /compat/i386/usr/ports

Then, append the mount points for the relevant directories:

$ mount -t devfs devfs /compat/i386/dev
$ mount -t nullfs /usr/ports /compat/i386/usr/ports

Then, issue the commands below to start idconfig:

$ chroot /compat/i386
$ setenv MACHINE i386
$ setenv UNAME_m i386
$ setenv UNAME_p i386
$ service ldconfig start

Then, head over to any directory and extract the package:

$ cd /usr/ports/emulators/i386-wine-devel
$ make package

Binary Image Activation

You can make configurations to the FreeBSD kernel so that every time a Windows binary file is opened, it is launched in Wine. This allows you to keep windows binaries like any other binaries on FreeBSD.

With root access, issue the command below:

# binmiscctl add wine --interpreter /usr/local/bin/wine \
--magic "\x4d\x5a\x90\x00\x03\x00\x00\x00\x04\x00\x00\x00\xff\xff\x00\x00\xb8\x00\x00\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" \
--size 20 --set-enabled

It is important to remember that Wine cannot detect the presence of infected windows applications, so make sure you’re getting the windows applications from official sources.

In conclusion

With Wine, you can run pretty much any Windows application, including video games. You’ll likely encounter some bugs and compatibility issues in your experience with Wine, especially when you work with heavier applications.

About the author

Younis Said

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.