Running GOG's Baldurs Gate II enhanced edition on FreeBSD 13

2021-05-05
3 min read

Baldur’s gate II is my favorite game, I spent a lot of hours playing this when I saw it at 50% discount in gog.com I just bought it!. Now I have played this on void Linux but would the Linux emulation layer on FreeBSD enough to run it?. It turns out that the Linux emulation has getting better on FreeBSD and the GOG game was working with just a couple of tweaks. First you will need to following the handbook on how to enable Linux emulation.

Installing

For making the game work, I installed the following packages for Linux emulation :

pkg install bash linux-c7-alsa-lib-1.1.8 linux-c7-alsa-lib-devel-1.1.8 linux-c7-alsa-plugins-oss-1.1.6_3 linux-c7-dri-18.3.4_4 linux-c7-elfutils-libelf-0.176_2 linux-c7-expat-2.1.0_4 linux-c7-fontconfig-2.13.0 linux-c7-freetype-2.8_2 linux-c7-libdrm-2.4.97 linux-c7-libglvnd-1.0.1 linux-c7-libpciaccess-0.14 linux-c7-libpng-1.5.13_3 linux-c7-nettle-2.7.1 linux-c7-openal-soft-1.16.0_3 linux-c7-wayland-1.15.0 linux-c7-xorg-libs-7.7_9 linux_base-c7-7.9.2009

then just type

bash baldur_s_gate_2_enhanced_edition_en_2_5_21851.sh

Then just follow along the ncurses. After the installation finishes go to the directory selected on the installation and you will find the following files:

docs
game
gameinfo
start.sh
support
uninstall-Baldurs Gate 2 Enhanced Edition.sh

For some reason the start.sh script concatenates the 32-bit and 64-bit version of the game, so I needed to modify the start.sh script as follows:

#!/bin/bash
# GOG.com (www.gog.com)
# Baldurs Gate 2 Enhanced Edition

# Initialization
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${CURRENT_DIR}"
source support/gog_com.shlib

# Game info
GAME_NAME="$(get_gameinfo 1)"
VERSION="$(get_gameinfo 2)"
VERSION_DEV="$(get_gameinfo 3)"

# Actions
run_game() {
echo "Running ${GAME_NAME}" 
 local bin32_name="BaldursGateII"
 local bin64_name="BaldursGateII64"
 local bin_path32="$CURRENT_DIR/game/"
 local bin_path64="$bin_path32"
 local lib_path32="$CURRENT_DIR/game/"
 local lib_path64="$lib_path32"
 execute_game  "${bin64_name}"  "${bin_path64}" "${lib_path64}"
}

default() {
# This will make saving games work
 HOME=/usr/home/${USER}  run_game
}

# Options
define_option "-s" "--start" "start ${GAME_NAME}" "run_game" "$@"

# Defaults
standard_options "$@"

But before playing we need to fetch the dependencies.

Dependencies

Here is how it looks with dependencies in place:

ldd /home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64:
/home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64:
/home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64: /lib64/libcrypto.so.1.0.0: no version information available (required by /home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64)
/home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64: /lib64/libssl.so.1.0.0: no version information available (required by /home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64)
/home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64: /lib64/libssl.so.1.0.0: no version information available (required by /home/neirac/GOG Games/Baldurs Gate 2 Enhanced Edition/game/BaldursGateII64)
	linux_vdso.so.1 =>  (0x00007ffffffff000)
	libopenal.so.1 => /lib64/libopenal.so.1 (0x0000000801400000)
	libGL.so.1 => /lib64/libGL.so.1 (0x0000000801800000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x0000000801c00000)
	librt.so.1 => /lib64/librt.so.1 (0x0000000802000000)
	libssl.so.1.0.0 => /lib64/libssl.so.1.0.0 (0x0000000802400000)
	libcrypto.so.1.0.0 => /lib64/libcrypto.so.1.0.0 (0x0000000802800000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x0000000802c00000)
	libX11.so.6 => /lib64/libX11.so.6 (0x0000000803000000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000000803400000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000000803800000)
	libm.so.6 => /lib64/libm.so.6 (0x0000000803c00000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000000804000000)
	libc.so.6 => /lib64/libc.so.6 (0x0000000804400000)
	libGLX.so.0 => /lib64/libGLX.so.0 (0x0000000804800000)
	libXext.so.6 => /lib64/libXext.so.6 (0x0000000804c00000)
	libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x0000000805000000)
	/lib64/ld-linux-x86-64.so.2 (0x00000008011ac000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x0000000805400000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x0000000805800000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x0000000805c00000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x0000000806000000)
	libz.so.1 => /lib64/libz.so.1 (0x0000000806400000)
	libxcb.so.1 => /lib64/libxcb.so.1 (0x0000000806800000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x0000000806c00000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x0000000807000000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x0000000807400000)
	libXau.so.6 => /lib64/libXau.so.6 (0x0000000807800000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x0000000807c00000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x0000000808000000)

You should see something like this, except that if you have not met the dependencies you will see that libssl.1.0.0 and libcrypto.so.1.0.0 shows as not found. The libssl.so.1.0.0 and libcrypto.so.1.0.0 rpm was downloaded from here as root install the downloaded rpm package as follows.

# cd /compat/linux
# rpm2cpio < /path/to/openssl098e-0.9.8e-29.el7.centos.3.x86_64.rpm | cpio -id

Then on /compat/linux/usr/lib64 create the following symlinks using the newly installed libs.

cd /compat/linux/usr/lib64
ln -s libssl.so.0.9.8e  libssl.so.1.0.0
ln -s libcrypto.so.0.9.8e  libcrypto.so.1.0.0  

After that you should see this on /compat/linux/usr/lib64

/compat/linux/usr/lib64/libssl.so.1.0.0 -> libssl.so.0.9.8e
/compat/linux/usr/lib64/libcrypto.so.1.0.0 -> libcrypto.so.0.9.8e

After that the game should work!. But saving games will not work.

Making save game work

For saving games to work, the following tweak is required:

sudo mkdir /compat/linux/usr/home
sudo mount_nullfs /usr/home /compat/linux/usr/home

References

FreeBSD handbook Linux emulation
FreeBSD forums steam emulation thread