https://wiki.winehq.org/api.php?action=feedcontributions&user=Fcasas&feedformat=atomWineHQ Wiki - User contributions [en]2024-03-29T14:39:22ZUser contributionsMediaWiki 1.41.0https://wiki.winehq.org/index.php?title=Pop!_os&diff=4251Pop! os2023-03-30T00:54:12Z<p>Fcasas: </p>
<hr />
<div>= Building Wine in Pop!_OS =<br />
<br />
While Pop!_OS, like Ubuntu, has support for multi-arch libraries, some i386 packages that are required to build a 32-bit version of Wine may conflict with pre-installed system packages, so you won't be able to install them.<br />
<br />
For this reason, in this tutorial we will use LXD to create a 64-bit Ubuntu LXC container were we will install the required packages, build Wine with WoW64 support, and then use it to our host system.<br />
<br />
We start by creating a working directory:<br />
<br />
mkdir $HOME/wine-dir<br />
cd $HOME/wine-dir<br />
<br />
== Setting up an LXC container ==<br />
<br />
This Section is based on the [https://support.system76.com/articles/containers/ official Pop!_OS documentation on containers].<br />
<br />
We use LXD to create the Ubuntu container.<br />
<br />
Install LXD through snap:<br />
<br />
$ sudo apt install snapd<br />
$ snap install lxd<br />
<br />
Add your current user to the lxd group so that it has the correct permissions to use the application:<br />
<br />
$ sudo usermod -aG lxd $USER<br />
$ reboot # to apply permissions.<br />
<br />
Initialize LXD:<br />
<br />
$ lxd init<br />
<br />
If you don't want containers to automatically start on boot:<br />
<br />
$ lxc profile set default boot.autostart false<br />
<br />
Launch an Ubuntu container:<br />
<br />
$ lxc launch ubuntu:20.04 wine-container<br />
<br />
Start the container:<br />
<br />
$ lxc list<br />
$ lxc start wine-container<br />
<br />
and update:<br />
<br />
$ lxc exec wine-container -- apt update<br />
<br />
To enter container, use the following command:<br />
<br />
$ lxc exec wine-container -- /bin/bash<br />
<br />
In order to share files between the host and the container, we have two options:<br />
<br />
* (a) Setup a shared host directory inside the LXC container in read-write mode.<br />
* (b) Pull and push directories every time we need to.<br />
<br />
Option (a) is probably the most comfortable in the long run, if you need to compile wine many times,<br />
but it requires special permissions and a longer setup.<br />
<br />
We will use Option (a) in this tutorial. For Option (b) see [[#Pushing and pulling files from the container without a shared directory]].<br />
<br />
== Setup a shared host directory inside the LXC container ==<br />
<br />
This Section is based on a [https://www.cyberciti.biz/faq/how-to-add-or-mount-directory-in-lxd-linux-container/ tutorial from nixCraft].<br />
<br />
=== Allow remaping the user ID in the host ===<br />
<br />
First, we need to know our user id in the host, for that purpose we can use the <code>id</code> command:<br />
<br />
$ id<br />
<br />
This is an example output:<br />
<br />
uid=1000(alice) gid=1000(alice) groups=1000(alice),4(adm),27(sudo),121(lpadmin),999(lxd)<br />
<br />
We see that our user (alice in this example) has user id (uid) 1000, and group id (gid) 1000.<br />
<br />
Now, we need to give permission to the root user (and thus, the LXD daemon) to remap the user id and the group id.<br />
<br />
We do that by adding new lines to the <code>/etc/subuid</code> and <code>/etc/subgid</code> files, respectively:<br />
<br />
$ echo "root:1000:1" | sudo tee -a /etc/subuid<br />
$ echo "root:1000:1" | sudo tee -a /etc/subgid<br />
<br />
where we need to replace the <code>1000</code> with our uid in the first line, and to replace the <code>1000</code> with our gid in the second line.<br />
<br />
=== Remap user ID inside the container ===<br />
<br />
The next step is to remap the user ID inside the container, so we need to enter it, with the aforementioned command:<br />
<br />
$ lxc exec wine-container -- /bin/bash<br />
<br />
After entering the container, we need to know if our user is already present inside:<br />
<br />
# grep '^alice' /etc/passwd<br />
<br />
If no line appears, we need to create it:<br />
<br />
# adduser alice<br />
<br />
We now need the uid and gid our user inside the container:<br />
<br />
# id alice<br />
<br />
This is an example output:<br />
<br />
uid=1001(alice) gid=1001(alice) groups=1001(alice)<br />
<br />
in this case the uid and the gid are 1001.<br />
<br />
Now we go back to the host, and map both the uid and gid from our user in the host to our user in the container:<br />
<br />
$ lxc config set wine-container raw.idmap "both 1000 1001"<br />
<br />
where we replace the 1000 and 1001 accordingly.<br />
<br />
And we restart the container:<br />
<br />
$ lxc restart wine-container<br />
<br />
Finally, we can mount the directory:<br />
<br />
$ lxc config device add wine-container wine-dir disk source=$HOME/wine-dir path=/root/wine-dir<br />
<br />
== Download the wine source code ==<br />
<br />
We clone the wine repo inside the wine-dir directory, in the host system:<br />
<br />
$ cd $HOME/wine-dir<br />
$ git clone https://gitlab.winehq.org/wine/wine.git wine-source<br />
<br />
We can then select a specific branch or tag:<br />
<br />
$ cd wine-source<br />
$ git checkout stable<br />
<br />
== Install wine dependencies in the container ==<br />
<br />
We need access to the source code repositories inside the container, so we enter the container again:<br />
<br />
$ lxc exec wine-container -- /bin/bash<br />
<br />
Uncomment all <code>deb-src</code> lines after uncommented <code>dev</code> lines in <code>/etc/apt/sources.list</code> using <code>nano</code> or <code>vim</code>:<br />
<br />
# nano /etc/apt/sources.list<br />
<br />
Also, add the i386 arch, and '''update''':<br />
<br />
# dpkg --add-architecture i386<br />
# apt update<br />
<br />
Install both x86-64 and i386 wine dependencies<br />
<br />
# apt-cache depends wine # Just lists distro's wine package dependencies.<br />
# apt build-dep wine64<br />
# apt build-dep wine32:i386<br />
# apt install gcc-multilib g++-multilib<br />
# apt install libx11-dev:i386 libfreetype-dev:i386 libgnutls28-dev:i386 ocl-icd-opencl-dev:i386 libvulkan-dev:i386<br />
# apt install gcc-mingw-w64<br />
<br />
In case you need more, check the [[Building Wine#Satisfying_Build_Dependencies | Building Wine]] page.<br />
<br />
This is a list of packages that works at the time of writing:<br />
<br />
# apt install libgl-dev libpulse-dev libdbus-1-dev libfontconfig-dev libxrender-dev gettext libxcursor-dev libxi-dev libxrandr-dev libxfixes-dev libxinerama-dev libxcomposite-dev libosmesa6-dev libpcap-dev libsane-dev libusb-1.0-0-dev libv4l-dev libgphoto2-dev libgphoto2-dev libudev-dev libsdl2-dev libcapi20-dev libkrb5-dev libopenal-dev libldap-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libpng-dev libjpeg-dev libtiff-dev<br />
<br />
and their i386 versions:<br />
<br />
# apt install libgl-dev:i386 libpulse-dev:i386 libdbus-1-dev:i386 libfontconfig-dev:i386 libxrender-dev:i386 gettext:i386 libxcursor-dev:i386 libxi-dev:i386 libxrandr-dev:i386 libxfixes-dev:i386 libxinerama-dev:i386 libxcomposite-dev:i386 libosmesa6-dev:i386 libpcap-dev:i386 libsane-dev:i386 libusb-1.0-0-dev:i386 libv4l-dev:i386 libgphoto2-dev:i386 libgphoto2-dev:i386 libudev-dev:i386 libsdl2-dev:i386 libcapi20-dev:i386 libkrb5-dev:i386 libopenal-dev:i386 libldap-dev:i386 libgstreamer1.0-dev:i386 libgstreamer-plugins-base1.0-dev:i386 libgstreamer-plugins-good1.0-dev:i386 libpng-dev:i386 libjpeg-dev:i386 libtiff-dev:i386<br />
<br />
We can also install ccache to lower our build times in case we need to build Wine many times:<br />
<br />
# apt install ccache<br />
<br />
And other packages that you may want, such as <code>valgrind:i386</code>.<br />
<br />
== Building 64-bit wine ==<br />
<br />
Let's start by building a 64-bit version of Wine inside the container.<br />
<br />
# cd /root/wine-dir<br />
# mkdir wine64<br />
# cd wine64<br />
# ../wine-source/configure --enable-win64 CC="ccache gcc" CROSSCC="ccache x86_64-w64-mingw32-gcc"<br />
<br />
Where the CROSSCC option allows cross compiling modules as PE.<br />
<br />
If you don't use ccache, remove <code>ccache </code> in both arguments.<br />
<br />
Read the configure script output. If you need more libraries, install them as in the previous step, otherwise continue.<br />
<br />
Run:<br />
<br />
# make -j8 # or as many CPU threads you have available.<br />
<br />
== Building 32-bit wine-tools ==<br />
<br />
Now we need to build a 32-bit version of Wine and inject it into our 64-bit Wine build to turn it into a WoW64 Wine,<br />
so that it supports 32-bit Windows applications, since most of them indeed are 32-bit.<br />
<br />
Before we build a 32-bit wine, we need the 32-bit wine-tools, so we make a provisional 32-bit version of Wine:<br />
<br />
# cd /root/wine-dir<br />
# mkdir wine32-tools<br />
# cd wine32-tools<br />
# ../wine-source/configure CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc"<br />
# make -j8 # or as many CPU threads you have available.<br />
<br />
If you don't use ccache, remove <code>ccache </code> from the options.<br />
<br />
== Building 32-bit wine ==<br />
<br />
# cd /root/wine-dir<br />
# mkdir wine32<br />
# cd wine32<br />
<br />
Configure and make:<br />
<br />
# ../wine-source/configure --with-wine64=../wine64 --with-wine-tools=../wine32-tools CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc"<br />
# make -j8 # or as many threads you have available.<br />
<br />
Again, if you don't use ccache, remove <code>ccache </code> from the options.<br />
<br />
== Fixing symbolic links ==<br />
<br />
Some links may have absolute paths for within the container. These need to be fixed.<br />
<br />
We can inspect all the symbolic links:<br />
<br />
$ cd $HOME/wine-dir<br />
$ find wine32 wine64 wine32-tools -type l -ls<br />
<br />
In particular the offending ones:<br />
<br />
$ find wine32 wine64 wine32-tools -type l -ls | grep '-> /root/'<br />
<br />
At the moment of writing, there are two links that need to be changed, the ones that the 64-bit build uses to refer to the 32-bit build:<br />
<br />
wine64/loader/wine -> /root/wine-dir/wine32/loader/wine<br />
wine64/loader/wine-preloader -> /root/wine-dir/wine32/loader/wine-preloader<br />
<br />
We change them inside the container:<br />
<br />
# cd /root/wine-dir<br />
# rm wine64/loader/wine wine64/loader/wine-preloader<br />
# ln -s ../../wine32/loader/wine wine64/loader/wine<br />
# ln -s ../../wine32/loader/wine-preloader wine64/loader/wine-preloader<br />
<br />
== Install runtime dependencies in the host system ==<br />
<br />
Wine requires access to some dynamic system libraries to run.<br />
<br />
As mentioned in the [[Building_Wine#Runtime_Dependencies]] section of the Building Wine page, the easiest way to achieve this is to install the wine package provided by the distribution in the host system:<br />
<br />
$ apt install wine<br />
<br />
Keep in mind that the <code>wine</code> command will execute the version of wine that this package installs, and not the one you build.<br />
<br />
You may also want to install optional runtime dependencies such as:<br />
<br />
$ apt install corefonts<br />
<br />
== Run wine ==<br />
<br />
You should be able to run wine from your build now, remember to use it with a prefix.<br />
<br />
$ PREFIX=$HOME/wine-dir/wine-prefix $HOME/wine-dir/wine64/wine --version<br />
<br />
We can stop the container now<br />
<br />
lxc stop wine-container<br />
<br />
== Pushing and pulling files from the container without a shared directory ==<br />
<br />
If you don't want to set up a shared directory between the host and the container, an alternative is to use the <code>lxc file push</code> and <code>lxc file pull</code> commands to send and retireve files from the container.<br />
<br />
The syntax is:<br />
<br />
lxc file push -r <host-src-directory> wine-container/root/<container-dst-directory><br />
lxc file pull -r wine-container/root/<container-dst-directory> <host-dst-directory><br />
<br />
Keep in mind that symbolic links end up invalid in the host system after pulling, because <code>lxc file pull</code> makes their paths absolute and respective to the container filesystem. Check the symbolic links using:<br />
<br />
$ find <pulled-directory> -type l -ls<br />
<br />
We can fix them running the following <code>link_fixer.sh</code> script in the same folder we pulled the directory.<br />
<br />
<syntaxhighlight lang="bash"><br />
#!/bin/bash<br />
<br />
PULLED_DIRECTORIES="$@"<br />
<br />
find $PULLED_DIRECTORIES -type l | while read symlink; do<br />
if [ ! -e "$symlink" ]; then<br />
old_path=$(readlink "$symlink")<br />
# Remove the '/root/' prefix and change it with the current path ${PWD}<br />
new_path=${old_path/\/root\//${PWD}\/}<br />
new_path=$(realpath --relative-to="$(dirname "$symlink")" "$new_path")<br />
( set -x; ln -f -s "$new_path" "$symlink")<br />
fi<br />
done<br />
</syntaxhighlight><br />
<br />
$ bash link_fixer.sh <host-dst-directory></div>Fcasashttps://wiki.winehq.org/index.php?title=Pop!_os&diff=4250Pop! os2023-03-30T00:53:10Z<p>Fcasas: </p>
<hr />
<div>= Building Wine in Pop!_OS =<br />
<br />
While Pop!_OS, like Ubuntu, has support for multi-arch libraries, some i386 packages that are required to build a 32-bit version of Wine may conflict with pre-installed system packages, so you won't be able to install them.<br />
<br />
For this reason, in this tutorial we will use LXD to create a 64-bit Ubuntu LXC container were we will install the required packages, build Wine with WoW64 support, and then use it to our host system.<br />
<br />
We start by creating a working directory:<br />
<br />
mkdir $HOME/wine-dir<br />
cd $HOME/wine-dir<br />
<br />
<br />
== Setting up an LXC container ==<br />
<br />
This Section is based on the [https://support.system76.com/articles/containers/ official Pop!_OS documentation on containers].<br />
<br />
We use LXD to create the Ubuntu container.<br />
<br />
Install LXD through snap:<br />
<br />
$ sudo apt install snapd<br />
$ snap install lxd<br />
<br />
<br />
Add your current user to the lxd group so that it has the correct permissions to use the application:<br />
<br />
$ sudo usermod -aG lxd $USER<br />
$ reboot # to apply permissions.<br />
<br />
Initialize LXD:<br />
<br />
$ lxd init<br />
<br />
<br />
If you don't want containers to automatically start on boot:<br />
<br />
$ lxc profile set default boot.autostart false<br />
<br />
<br />
Launch an Ubuntu container:<br />
<br />
$ lxc launch ubuntu:20.04 wine-container<br />
<br />
<br />
Start the container:<br />
<br />
$ lxc list<br />
$ lxc start wine-container<br />
<br />
and update:<br />
<br />
$ lxc exec wine-container -- apt update<br />
<br />
<br />
To enter container, use the following command:<br />
<br />
$ lxc exec wine-container -- /bin/bash<br />
<br />
<br />
In order to share files between the host and the container, we have two options:<br />
<br />
* (a) Setup a shared host directory inside the LXC container in read-write mode.<br />
* (b) Pull and push directories every time we need to.<br />
<br />
Option (a) is probably the most comfortable in the long run, if you need to compile wine many times,<br />
but it requires special permissions and a longer setup.<br />
<br />
We will use Option (a) in this tutorial. For Option (b) see [[#Pushing and pulling files from the container without a shared directory]].<br />
<br />
<br />
== Setup a shared host directory inside the LXC container ==<br />
<br />
This Section is based on a [https://www.cyberciti.biz/faq/how-to-add-or-mount-directory-in-lxd-linux-container/ tutorial from nixCraft].<br />
<br />
=== Allow remaping the user ID in the host ===<br />
<br />
First, we need to know our user id in the host, for that purpose we can use the <code>id</code> command:<br />
<br />
$ id<br />
<br />
This is an example output:<br />
<br />
uid=1000(alice) gid=1000(alice) groups=1000(alice),4(adm),27(sudo),121(lpadmin),999(lxd)<br />
<br />
We see that our user (alice in this example) has user id (uid) 1000, and group id (gid) 1000.<br />
<br />
Now, we need to give permission to the root user (and thus, the LXD daemon) to remap the user id and the group id.<br />
<br />
We do that by adding new lines to the <code>/etc/subuid</code> and <code>/etc/subgid</code> files, respectively:<br />
<br />
$ echo "root:1000:1" | sudo tee -a /etc/subuid<br />
$ echo "root:1000:1" | sudo tee -a /etc/subgid<br />
<br />
where we need to replace the <code>1000</code> with our uid in the first line, and to replace the <code>1000</code> with our gid in the second line.<br />
<br />
=== Remap user ID inside the container ===<br />
<br />
The next step is to remap the user ID inside the container, so we need to enter it, with the aforementioned command:<br />
<br />
$ lxc exec wine-container -- /bin/bash<br />
<br />
After entering the container, we need to know if our user is already present inside:<br />
<br />
# grep '^alice' /etc/passwd<br />
<br />
If no line appears, we need to create it:<br />
<br />
# adduser alice<br />
<br />
We now need the uid and gid our user inside the container:<br />
<br />
# id alice<br />
<br />
This is an example output:<br />
<br />
uid=1001(alice) gid=1001(alice) groups=1001(alice)<br />
<br />
in this case the uid and the gid are 1001.<br />
<br />
Now we go back to the host, and map both the uid and gid from our user in the host to our user in the container:<br />
<br />
$ lxc config set wine-container raw.idmap "both 1000 1001"<br />
<br />
where we replace the 1000 and 1001 accordingly.<br />
<br />
And we restart the container:<br />
<br />
$ lxc restart wine-container<br />
<br />
Finally, we can mount the directory:<br />
<br />
$ lxc config device add wine-container wine-dir disk source=$HOME/wine-dir path=/root/wine-dir<br />
<br />
== Download the wine source code ==<br />
<br />
We clone the wine repo inside the wine-dir directory, in the host system:<br />
<br />
$ cd $HOME/wine-dir<br />
$ git clone https://gitlab.winehq.org/wine/wine.git wine-source<br />
<br />
We can then select a specific branch or tag:<br />
<br />
$ cd wine-source<br />
$ git checkout stable<br />
<br />
== Install wine dependencies in the container ==<br />
<br />
We need access to the source code repositories inside the container, so we enter the container again:<br />
<br />
$ lxc exec wine-container -- /bin/bash<br />
<br />
Uncomment all <code>deb-src</code> lines after uncommented <code>dev</code> lines in <code>/etc/apt/sources.list</code> using <code>nano</code> or <code>vim</code>:<br />
<br />
# nano /etc/apt/sources.list<br />
<br />
Also, add the i386 arch, and '''update''':<br />
<br />
# dpkg --add-architecture i386<br />
# apt update<br />
<br />
Install both x86-64 and i386 wine dependencies<br />
<br />
# apt-cache depends wine # Just lists distro's wine package dependencies.<br />
# apt build-dep wine64<br />
# apt build-dep wine32:i386<br />
# apt install gcc-multilib g++-multilib<br />
# apt install libx11-dev:i386 libfreetype-dev:i386 libgnutls28-dev:i386 ocl-icd-opencl-dev:i386 libvulkan-dev:i386<br />
# apt install gcc-mingw-w64<br />
<br />
In case you need more, check the [[Building Wine#Satisfying_Build_Dependencies | Building Wine]] page.<br />
<br />
This is a list of packages that works at the time of writing:<br />
<br />
# apt install libgl-dev libpulse-dev libdbus-1-dev libfontconfig-dev libxrender-dev gettext libxcursor-dev libxi-dev libxrandr-dev libxfixes-dev libxinerama-dev libxcomposite-dev libosmesa6-dev libpcap-dev libsane-dev libusb-1.0-0-dev libv4l-dev libgphoto2-dev libgphoto2-dev libudev-dev libsdl2-dev libcapi20-dev libkrb5-dev libopenal-dev libldap-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libpng-dev libjpeg-dev libtiff-dev<br />
<br />
and their i386 versions:<br />
<br />
# apt install libgl-dev:i386 libpulse-dev:i386 libdbus-1-dev:i386 libfontconfig-dev:i386 libxrender-dev:i386 gettext:i386 libxcursor-dev:i386 libxi-dev:i386 libxrandr-dev:i386 libxfixes-dev:i386 libxinerama-dev:i386 libxcomposite-dev:i386 libosmesa6-dev:i386 libpcap-dev:i386 libsane-dev:i386 libusb-1.0-0-dev:i386 libv4l-dev:i386 libgphoto2-dev:i386 libgphoto2-dev:i386 libudev-dev:i386 libsdl2-dev:i386 libcapi20-dev:i386 libkrb5-dev:i386 libopenal-dev:i386 libldap-dev:i386 libgstreamer1.0-dev:i386 libgstreamer-plugins-base1.0-dev:i386 libgstreamer-plugins-good1.0-dev:i386 libpng-dev:i386 libjpeg-dev:i386 libtiff-dev:i386<br />
<br />
We can also install ccache to lower our build times in case we need to build Wine many times:<br />
<br />
# apt install ccache<br />
<br />
And other packages that you may want, such as <code>valgrind:i386</code>.<br />
<br />
== Building 64-bit wine ==<br />
<br />
Let's start by building a 64-bit version of Wine inside the container.<br />
<br />
# cd /root/wine-dir<br />
# mkdir wine64<br />
# cd wine64<br />
# ../wine-source/configure --enable-win64 CC="ccache gcc" CROSSCC="ccache x86_64-w64-mingw32-gcc"<br />
<br />
Where the CROSSCC option allows cross compiling modules as PE.<br />
<br />
If you don't use ccache, remove <code>ccache </code> in both arguments.<br />
<br />
Read the configure script output. If you need more libraries, install them as in the previous step, otherwise continue.<br />
<br />
Run:<br />
<br />
# make -j8 # or as many CPU threads you have available.<br />
<br />
== Building 32-bit wine-tools ==<br />
<br />
Now we need to build a 32-bit version of Wine and inject it into our 64-bit Wine build to turn it into a WoW64 Wine,<br />
so that it supports 32-bit Windows applications, since most of them indeed are 32-bit.<br />
<br />
Before we build a 32-bit wine, we need the 32-bit wine-tools, so we make a provisional 32-bit version of Wine:<br />
<br />
# cd /root/wine-dir<br />
# mkdir wine32-tools<br />
# cd wine32-tools<br />
# ../wine-source/configure CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc"<br />
# make -j8 # or as many CPU threads you have available.<br />
<br />
If you don't use ccache, remove <code>ccache </code> from the options.<br />
<br />
== Building 32-bit wine ==<br />
<br />
# cd /root/wine-dir<br />
# mkdir wine32<br />
# cd wine32<br />
<br />
Configure and make:<br />
<br />
# ../wine-source/configure --with-wine64=../wine64 --with-wine-tools=../wine32-tools CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc"<br />
# make -j8 # or as many threads you have available.<br />
<br />
Again, if you don't use ccache, remove <code>ccache </code> from the options.<br />
<br />
== Fixing symbolic links ==<br />
<br />
Some links may have absolute paths for within the container. These need to be fixed.<br />
<br />
We can inspect all the symbolic links:<br />
<br />
$ cd $HOME/wine-dir<br />
$ find wine32 wine64 wine32-tools -type l -ls<br />
<br />
<br />
In particular the offending ones:<br />
<br />
$ find wine32 wine64 wine32-tools -type l -ls | grep '-> /root/'<br />
<br />
<br />
At the moment of writing, there are two links that need to be changed, the ones that the 64-bit build uses to refer to the 32-bit build:<br />
<br />
wine64/loader/wine -> /root/wine-dir/wine32/loader/wine<br />
wine64/loader/wine-preloader -> /root/wine-dir/wine32/loader/wine-preloader<br />
<br />
We change them inside the container:<br />
<br />
# cd /root/wine-dir<br />
# rm wine64/loader/wine wine64/loader/wine-preloader<br />
# ln -s ../../wine32/loader/wine wine64/loader/wine<br />
# ln -s ../../wine32/loader/wine-preloader wine64/loader/wine-preloader<br />
<br />
== Install runtime dependencies in the host system ==<br />
<br />
Wine requires access to some dynamic system libraries to run.<br />
<br />
As mentioned in the [[Building_Wine#Runtime_Dependencies]] section of the Building Wine page, the easiest way to achieve this is to install the wine package provided by the distribution in the host system:<br />
<br />
$ apt install wine<br />
<br />
Keep in mind that the <code>wine</code> command will execute the version of wine that this package installs, and not the one you build.<br />
<br />
You may also want to install optional runtime dependencies such as:<br />
<br />
$ apt install corefonts<br />
<br />
== Run wine ==<br />
<br />
You should be able to run wine from your build now, remember to use it with a prefix.<br />
<br />
$ PREFIX=$HOME/wine-dir/wine-prefix $HOME/wine-dir/wine64/wine --version<br />
<br />
We can stop the container now<br />
<br />
lxc stop wine-container<br />
<br />
== Pushing and pulling files from the container without a shared directory ==<br />
<br />
If you don't want to set up a shared directory between the host and the container, an alternative is to use the <code>lxc file push</code> and <code>lxc file pull</code> commands to send and retireve files from the container.<br />
<br />
The syntax is:<br />
<br />
lxc file push -r <host-src-directory> wine-container/root/<container-dst-directory><br />
lxc file pull -r wine-container/root/<container-dst-directory> <host-dst-directory><br />
<br />
Keep in mind that symbolic links end up invalid in the host system after pulling, because <code>lxc file pull</code> makes their paths absolute and respective to the container filesystem. Check the symbolic links using:<br />
<br />
$ find <pulled-directory> -type l -ls<br />
<br />
We can fix them running the following <code>link_fixer.sh</code> script in the same folder we pulled the directory.<br />
<br />
<syntaxhighlight lang="bash"><br />
#!/bin/bash<br />
<br />
PULLED_DIRECTORIES="$@"<br />
<br />
find $PULLED_DIRECTORIES -type l | while read symlink; do<br />
if [ ! -e "$symlink" ]; then<br />
old_path=$(readlink "$symlink")<br />
# Remove the '/root/' prefix and change it with the current path ${PWD}<br />
new_path=${old_path/\/root\//${PWD}\/}<br />
new_path=$(realpath --relative-to="$(dirname "$symlink")" "$new_path")<br />
( set -x; ln -f -s "$new_path" "$symlink")<br />
fi<br />
done<br />
</syntaxhighlight><br />
<br />
$ bash link_fixer.sh <host-dst-directory></div>Fcasashttps://wiki.winehq.org/index.php?title=Pop!_os&diff=4249Pop! os2023-03-30T00:44:11Z<p>Fcasas: Created page with "= Building Wine in Pop!_OS = While Pop!_OS, like Ubuntu, has support for multi-arch libraries, some i386 packages that are required to build a 32-bit version of Wine may conf..."</p>
<hr />
<div>= Building Wine in Pop!_OS =<br />
<br />
While Pop!_OS, like Ubuntu, has support for multi-arch libraries, some i386 packages that are required to build a 32-bit version of Wine may conflict with pre-installed system packages, so you won't be able to install them.<br />
<br />
For this reason, in this tutorial we will use LXD to create a 64-bit Ubuntu LXC container were we will install the required packages, build Wine with WoW64 support, and then use it to our host system.<br />
<br />
We start by creating a working directory:<br />
<br />
<syntaxhighlight><br />
mkdir $HOME/wine-dir<br />
cd $HOME/wine-dir<br />
</syntaxhighlight><br />
<br />
== Setting up an LXC container ==<br />
<br />
This Section is based on the [https://support.system76.com/articles/containers/ official Pop!_OS documentation on containers].<br />
<br />
We use LXD to create the Ubuntu container.<br />
<br />
Install LXD through snap:<br />
<br />
<syntaxhighlight><br />
$ sudo apt install snapd<br />
$ snap install lxd<br />
</syntaxhighlight><br />
<br />
Add your current user to the lxd group so that it has the correct permissions to use the application:<br />
<br />
<syntaxhighlight><br />
$ sudo usermod -aG lxd $USER<br />
$ reboot # to apply permissions.<br />
</syntaxhighlight><br />
<br />
Initialize LXD:<br />
<syntaxhighlight><br />
$ lxd init<br />
</syntaxhighlight><br />
<br />
If you don't want containers to automatically start on boot:<br />
<syntaxhighlight><br />
$ lxc profile set default boot.autostart false<br />
</syntaxhighlight><br />
<br />
Launch an Ubuntu container:<br />
<syntaxhighlight><br />
$ lxc launch ubuntu:20.04 wine-container<br />
</syntaxhighlight><br />
<br />
Start the container:<br />
<syntaxhighlight><br />
$ lxc list<br />
$ lxc start wine-container<br />
</syntaxhighlight><br />
and update:<br />
<syntaxhighlight><br />
$ lxc exec wine-container -- apt update<br />
</syntaxhighlight><br />
<br />
To enter container, use the following command:<br />
<syntaxhighlight><br />
$ lxc exec wine-container -- /bin/bash<br />
</syntaxhighlight><br />
<br />
In order to share files between the host and the container, we have two options:<br />
<br />
* (a) Setup a shared host directory inside the LXC container in read-write mode.<br />
* (b) Pull and push directories every time we need to.<br />
<br />
Option (a) is probably the most comfortable in the long run, if you need to compile wine many times,<br />
but it requires special permissions and a longer setup.<br />
<br />
We will use Option (a) in this tutorial. For Option (b) see [[#Pushing and pulling files from the container without a shared directory]].<br />
<br />
<br />
== Setup a shared host directory inside the LXC container ==<br />
<br />
This Section is based on a [https://www.cyberciti.biz/faq/how-to-add-or-mount-directory-in-lxd-linux-container/ tutorial from nixCraft].<br />
<br />
=== Allow remaping the user ID in the host ===<br />
<br />
First, we need to know our user id in the host, for that purpose we can use the <code>id</code> command:<br />
<br />
<syntaxhighlight><br />
$ id<br />
</syntaxhighlight><br />
<br />
This is an example output:<br />
<syntaxhighlight><br />
uid=1000(alice) gid=1000(alice) groups=1000(alice),4(adm),27(sudo),121(lpadmin),999(lxd)<br />
</syntaxhighlight><br />
<br />
We see that our user (alice in this example) has user id (uid) 1000, and group id (gid) 1000.<br />
<br />
Now, we need to give permission to the root user (and thus, the LXD daemon) to remap the user id and the group id.<br />
<br />
We do that by adding new lines to the <code>/etc/subuid</code> and <code>/etc/subgid</code> files, respectively:<br />
<br />
<syntaxhighlight><br />
$ echo "root:1000:1" | sudo tee -a /etc/subuid<br />
$ echo "root:1000:1" | sudo tee -a /etc/subgid<br />
</syntaxhighlight><br />
<br />
where we need to replace the <code>1000</code> with our uid in the first line, and to replace the <code>1000</code> with our gid in the second line.<br />
<br />
=== Remap user ID inside the container ===<br />
<br />
The next step is to remap the user ID inside the container, so we need to enter it, with the aforementioned command:<br />
<br />
<syntaxhighlight><br />
$ lxc exec wine-container -- /bin/bash<br />
</syntaxhighlight><br />
<br />
After entering the container, we need to know if our user is already present inside:<br />
<br />
<syntaxhighlight><br />
# grep '^alice' /etc/passwd<br />
</syntaxhighlight><br />
<br />
If no line appears, we need to create it:<br />
<br />
<syntaxhighlight><br />
# adduser alice<br />
</syntaxhighlight><br />
<br />
We now need the uid and gid our user inside the container:<br />
<br />
<syntaxhighlight><br />
# id alice<br />
</syntaxhighlight><br />
<br />
This is an example output:<br />
<syntaxhighlight><br />
uid=1001(alice) gid=1001(alice) groups=1001(alice)<br />
</syntaxhighlight><br />
<br />
in this case the uid and the gid are 1001.<br />
<br />
Now we go back to the host, and map both the uid and gid from our user in the host to our user in the container:<br />
<br />
<syntaxhighlight><br />
$ lxc config set wine-container raw.idmap "both 1000 1001"<br />
</syntaxhighlight><br />
<br />
where we replace the 1000 and 1001 accordingly.<br />
<br />
And we restart the container:<br />
<br />
<syntaxhighlight><br />
$ lxc restart wine-container<br />
</syntaxhighlight><br />
<br />
Finally, we can mount the directory:<br />
<br />
<syntaxhighlight><br />
$ lxc config device add wine-container wine-dir disk source=$HOME/wine-dir path=/root/wine-dir<br />
</syntaxhighlight><br />
<br />
== Download the wine source code ==<br />
<br />
We clone the wine repo inside the wine-dir directory, in the host system:<br />
<syntaxhighlight><br />
$ cd $HOME/wine-dir<br />
$ git clone https://gitlab.winehq.org/wine/wine.git wine-source<br />
</syntaxhighlight><br />
<br />
We can then select a specific branch or tag:<br />
<syntaxhighlight><br />
$ cd wine-source<br />
$ git checkout stable<br />
</syntaxhighlight><br />
<br />
== Install wine dependencies in the container ==<br />
<br />
We need access to the source code repositories inside the container, so we enter the container again:<br />
<syntaxhighlight><br />
$ lxc exec wine-container -- /bin/bash<br />
</syntaxhighlight><br />
<br />
Uncomment all <code>deb-src</code> lines after uncommented <code>dev</code> lines in <code>/etc/apt/sources.list</code> using <code>nano</code> or <code>vim</code>:<br />
<syntaxhighlight><br />
# nano /etc/apt/sources.list<br />
</syntaxhighlight><br />
<br />
Also, add the i386 arch, and '''update''':<br />
<syntaxhighlight><br />
# dpkg --add-architecture i386<br />
# apt update<br />
</syntaxhighlight><br />
<br />
Install both x86-64 and i386 wine dependencies<br />
<syntaxhighlight><br />
# apt-cache depends wine # Just lists distro's wine package dependencies.<br />
# apt build-dep wine64<br />
# apt build-dep wine32:i386<br />
# apt install gcc-multilib g++-multilib<br />
# apt install libx11-dev:i386 libfreetype-dev:i386 libgnutls28-dev:i386 ocl-icd-opencl-dev:i386 libvulkan-dev:i386<br />
# apt install gcc-mingw-w64<br />
</syntaxhighlight><br />
<br />
You may need more, check the [[Building Wine#Satisfying_Build_Dependencies | Building Wine]] page.<br />
<br />
This is a list of packages that works at the time of writing:<br />
<br />
<syntaxhighlight><br />
# apt install libgl-dev libpulse-dev libdbus-1-dev libfontconfig-dev libxrender-dev gettext libxcursor-dev libxi-dev libxrandr-dev libxfixes-dev libxinerama-dev libxcomposite-dev libosmesa6-dev libpcap-dev libsane-dev libusb-1.0-0-dev libv4l-dev libgphoto2-dev libgphoto2-dev libudev-dev libsdl2-dev libcapi20-dev libkrb5-dev libopenal-dev libldap-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libpng-dev libjpeg-dev libtiff-dev<br />
</syntaxhighlight><br />
<br />
and their i386 versions:<br />
<br />
<syntaxhighlight><br />
# apt install libgl-dev:i386 libpulse-dev:i386 libdbus-1-dev:i386 libfontconfig-dev:i386 libxrender-dev:i386 gettext:i386 libxcursor-dev:i386 libxi-dev:i386 libxrandr-dev:i386 libxfixes-dev:i386 libxinerama-dev:i386 libxcomposite-dev:i386 libosmesa6-dev:i386 libpcap-dev:i386 libsane-dev:i386 libusb-1.0-0-dev:i386 libv4l-dev:i386 libgphoto2-dev:i386 libgphoto2-dev:i386 libudev-dev:i386 libsdl2-dev:i386 libcapi20-dev:i386 libkrb5-dev:i386 libopenal-dev:i386 libldap-dev:i386 libgstreamer1.0-dev:i386 libgstreamer-plugins-base1.0-dev:i386 libgstreamer-plugins-good1.0-dev:i386 libpng-dev:i386 libjpeg-dev:i386 libtiff-dev:i386<br />
</syntaxhighlight><br />
<br />
We can also install ccache to lower our build times in case we need to build Wine many times:<br />
<syntaxhighlight><br />
# apt install ccache<br />
</syntaxhighlight><br />
<br />
And other packages that you may want, such as <code>valgrind:i386</code>.<br />
<br />
== Building 64-bit wine ==<br />
<br />
Let's start by building a 64-bit version of Wine inside the container.<br />
<br />
<syntaxhighlight><br />
# cd /root/wine-dir<br />
# mkdir wine64<br />
# cd wine64<br />
# ../wine-source/configure --enable-win64 CC="ccache gcc" CROSSCC="ccache x86_64-w64-mingw32-gcc"<br />
</syntaxhighlight><br />
<br />
Where the CROSSCC option allows cross compiling modules as PE.<br />
<br />
If you don't use ccache, remove <code>ccache </code> in both arguments.<br />
<br />
Read the configure script output. If you need more libraries, install them as in the previous step, otherwise continue.<br />
<br />
Run:<br />
<br />
<syntaxhighlight><br />
# make -j8 # or as many CPU threads you have available.<br />
</syntaxhighlight><br />
<br />
== Building 32-bit wine-tools ==<br />
<br />
Now we need to build a 32-bit version of Wine and inject it into our 64-bit Wine build to turn it into a WoW64 Wine,<br />
so that it supports 32-bit Windows applications, since most of them indeed are 32-bit.<br />
<br />
Before we build a 32-bit wine, we need the 32-bit wine-tools, so we make a provisional 32-bit version of Wine:<br />
<br />
<syntaxhighlight><br />
# cd /root/wine-dir<br />
# mkdir wine32-tools<br />
# cd wine32-tools<br />
# ../wine-source/configure CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc"<br />
# make -j8 # or as many CPU threads you have available.<br />
</syntaxhighlight><br />
<br />
If you don't use ccache, remove <code>ccache </code> from the options.<br />
<br />
== Building 32-bit wine ==<br />
<br />
<syntaxhighlight><br />
# cd /root/wine-dir<br />
# mkdir wine32<br />
# cd wine32<br />
</syntaxhighlight><br />
<br />
Configure and make:<br />
<syntaxhighlight><br />
# ../wine-source/configure --with-wine64=../wine64 --with-wine-tools=../wine32-tools CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc"<br />
# make -j8 # or as many threads you have available.<br />
</syntaxhighlight><br />
<br />
Again, if you don't use ccache, remove <code>ccache </code> from the options.<br />
<br />
== Fixing symbolic links ==<br />
<br />
Some links may have absolute paths for within the container. These need to be fixed.<br />
<br />
We can inspect all the symbolic links:<br />
<syntaxhighlight><br />
$ cd $HOME/wine-dir<br />
$ find wine32 wine64 wine32-tools -type l -ls<br />
</syntaxhighlight><br />
<br />
In particular the offending ones:<br />
<syntaxhighlight><br />
$ find wine32 wine64 wine32-tools -type l -ls | grep '-> /root/'<br />
</syntaxhighlight><br />
<br />
At the moment of writing, there are two links that need to be changed, the ones that the 64-bit build uses to refer to the 32-bit build:<br />
<br />
<syntaxhighlight><br />
... wine64/loader/wine -> /root/wine-dir/wine32/loader/wine<br />
... wine64/loader/wine-preloader -> /root/wine-dir/wine32/loader/wine-preloader<br />
</syntaxhighlight><br />
<br />
We change them inside the container:<br />
<br />
<syntaxhighlight><br />
# cd /root/wine-dir<br />
# rm wine64/loader/wine wine64/loader/wine-preloader<br />
# ln -s ../../wine32/loader/wine wine64/loader/wine<br />
# ln -s ../../wine32/loader/wine-preloader wine64/loader/wine-preloader<br />
</syntaxhighlight><br />
<br />
== Install runtime dependencies in the host system ==<br />
<br />
Wine requires access to some dynamic system libraries to run.<br />
<br />
As mentioned in the [[Building_Wine#Runtime_Dependencies]] section of the Building Wine page, the easiest way to achieve this is to install the wine package provided by the distribution in the host system:<br />
<br />
<syntaxhighlight><br />
$ apt install wine<br />
</syntaxhighlight><br />
<br />
Keep in mind that the <code>wine</code> command will execute the version of wine that this package installs, and not the one you build.<br />
<br />
You may also want to install optional runtime dependencies such as:<br />
<syntaxhighlight><br />
$ apt install corefonts<br />
</syntaxhighlight><br />
<br />
== Run wine ==<br />
<br />
You should be able to run wine from your build now, remember to use it with a prefix.<br />
<br />
<syntaxhighlight><br />
$ PREFIX=$HOME/wine-dir/wine-prefix $HOME/wine-dir/wine64/wine --version<br />
</syntaxhighlight><br />
<br />
We can stop the container now<br />
<br />
<syntaxhighlight><br />
lxc stop wine-container<br />
</syntaxhighlight><br />
<br />
== Pushing and pulling files from the container without a shared directory ==<br />
<br />
If you don't want to set up a shared directory between the host and the container, an alternative is to use the <code>lxc file push</code> and <code>lxc file pull</code> commands to send and retireve files from the container.<br />
<br />
The syntax is:<br />
<br />
<syntaxhighlight><br />
lxc file push -r <host-src-directory> wine-container/root/<container-dst-directory><br />
lxc file pull -r wine-container/root/<container-dst-directory> <host-dst-directory><br />
</syntaxhighlight><br />
<br />
Keep in mind that symbolic links end up invalid in the host system after pulling, because <code>lxc file pull</code> makes their paths absolute and respective to the container filesystem. Check the symbolic links using:<br />
<br />
<syntaxhighlight><br />
$ find <pulled-directory> -type l -ls<br />
</syntaxhighlight><br />
<br />
We can fix them running the following <code>link_fixer.sh</code> script in the same folder we pulled the directory.<br />
<br />
<syntaxhighlight lang="bash"><br />
#!/bin/bash<br />
<br />
PULLED_DIRECTORIES="$@"<br />
<br />
find $PULLED_DIRECTORIES -type l | while read symlink; do<br />
if [ ! -e "$symlink" ]; then<br />
old_path=$(readlink "$symlink")<br />
# Remove the '/root/' prefix and change it with the current path ${PWD}<br />
new_path=${old_path/\/root\//${PWD}\/}<br />
new_path=$(realpath --relative-to="$(dirname "$symlink")" "$new_path")<br />
( set -x; ln -f -s "$new_path" "$symlink")<br />
fi<br />
done<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight><br />
$ bash link_fixer.sh <host-dst-directory><br />
</syntaxhighlight></div>Fcasashttps://wiki.winehq.org/index.php?title=Building_a_MinGW_WoW64_Wine_with_a_custom_vkd3d_build&diff=3912Building a MinGW WoW64 Wine with a custom vkd3d build2022-03-23T17:55:10Z<p>Fcasas: </p>
<hr />
<div>As of version 7.4, Wine comes with a bundled version of vkd3d.<br />
<br />
However, if you want to use a more modern version of vkd3d, apply certain patches to it, or test fixes of your own, you will need Wine to work with a custom version of vkd3d.<br />
<br />
For this purpose, it is necessary to build both projects and link them correctly.<br />
<br />
Compiling a Windows on Windows (WoW) version of Wine, so that it supports both 32-bits and 64-bits Windows applications – which is often desired – adds a layer of complexity to the build process.<br />
<br />
Furthermore, you may want to use MinGW to cross-compile the Wine executables and DLLs in the Windows PE format. This is because various programs expect the on-disk DLLs to look like real PE DLLs.<br />
<br />
This guide aims to help you through that process.<br />
<br />
= Preliminaries =<br />
<br />
== Install Wine dependencies ==<br />
<br />
First, install the dependencies listed in the [[Building Wine#Satisfying Build Dependencies | Building Wine]] article.<br />
<br />
Remember to install the <code>:i386</code> version of the required packages too (if your system has multi-lib support).<br />
<br />
The '''mingw''' and '''vulkan''' packages are of particular importance.<br />
<br />
It is also recommended that you install <code>ccache</code>, as it may save us a considerable amount of time during the builds.<br />
<br />
{{Info}} If you have a system-wide installation of vkd3d, it may be good to uninstall it using <code>make uninstall</code>. To ensure that the correct version of vkd3d is linked in this tutorial.<br />
<br />
== Directory organization ==<br />
<br />
For this tutorial we will need to create several build directories and have several git repositories. For this reason, we will start by creating a common directory for them:<br />
<br />
<syntaxhighlight lang="bash"><br />
mkdir -p $HOME/wine-dirs<br />
</syntaxhighlight><br />
<br />
== Cloning <code>wine</code> and <code>vkd3d</code> repositories ==<br />
<br />
First, we clone the <code>wine</code> repository if we haven't already:<br />
<br />
<syntaxhighlight lang="bash"><br />
git clone git://source.winehq.org/git/wine.git $HOME/wine-dirs/wine-git<br />
</syntaxhighlight><br />
<br />
We also need to clone <code>vkd3d</code> repository if we haven't already:<br />
<br />
<syntaxhighlight lang="bash"><br />
git clone git://source.winehq.org/git/vkd3d.git $HOME/wine-dirs/vkd3d-git<br />
</syntaxhighlight><br />
<br />
In case you already have these repositories somewhere else, you can create symbolic links inside <code>wine-dirs</code> instead:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
ln -s <relative-path-to-wine-repo> wine-git<br />
ln -s <relative-path-to-vkd3d-repo> vkd3d-git<br />
</syntaxhighlight><br />
<br />
Now it is a good time to pick a particular branch or apply the desired patches to these repositories.<br />
<br />
{{Info}} At the time of writing, the upstream Wine master branch is missing a patch that makes the d3dcompiler DLL use vkd3d's HLSL compiler for <code>D3DCompile()</code> and <code>D3DCompile2()</code>.<br />
In case you want to add this patch, execute the following commands to download this patch and apply it.<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs/wine-git<br />
wget https://source.winehq.org/patches/data/228839<br />
git am 228839<br />
</syntaxhighlight><br />
<br />
= Building =<br />
<br />
== Build a provisional 64-bit Wine ==<br />
<br />
In order to build 64-bit vkd3d we need some dependencies that can be built from the Wine repository. Namely, WIDL and the vulkan-1 DLLs.<br />
<br />
For that purpose we need first a provisional 64-bit MinGW Wine installation, so we start by creating a folder:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine64p<br />
</syntaxhighlight><br />
<br />
We run the Wine <code>configure</code> script from the installation folder<br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine64p<br />
../wine-git/configure --enable-win64 --disable-tests \<br />
CC='ccache gcc' CROSSCC='ccache x86_64-w64-mingw32-gcc'<br />
</syntaxhighlight><br />
<br />
Note that we use <code>CROSSCC=</code> to indicate the compiler used for cross-compilation, in this case we need the 64-bit mingw32 compiler. We prepend <code>ccache </code> which works as a wrapper for the compiler. The same is done for the regular C compiler, <code>gcc</code>, passed with the <code>CC=</code> variable.<br />
<br />
Since this is just a provisional build of wine, we use <code>--disable-tests</code> to speed up the compilation times.<br />
<br />
Note that to know about other parameters for the <code>configure</code> script we can use:<br />
<br />
<syntaxhighlight lang="bash"><br />
../wine-git/configure --help<br />
</syntaxhighlight><br />
<br />
Also, if something from the configure command fails, it is useful to search in <code>config.log</code> for the line that contains the pertinent error, and the lines before and after it.<br />
<br />
Once the configure script has finished, we build Wine. We can pass <code>-j<n></code> to use <code><n></code> threads.<br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
== Build a 64-bit vkd3d installation ==<br />
<br />
Now we need to do the 64-bit vkd3d build. For that purpose we will also need the Vulkan headers.<br />
One way of getting them is downloading the [https://vulkan.lunarg.com Vulkan SDK].<br />
<br />
Alternativelly, you can get them from the official [https://github.com/KhronosGroup/Vulkan-Headers Vulkan-Headers] repository. Similarly for the [https://github.com/KhronosGroup/SPIRV-Headers SPIRV-Headers] if you want to build with <code>--with-spirv-tools</code>.<br />
<br />
Assuming you downloaded and extracted the SDK, move it to the common directory:<br />
<br />
<syntaxhighlight lang="bash"><br />
mv <vulkan sdk path> $HOME/wine-dirs/vulkan-sdk<br />
</syntaxhighlight><br />
<br />
You must change the first argument of the <code>mv</code> command depending on where you downloaded and extracted the SDK. e.g. <code>~/Downloads/vulkansdk-linux-x86_64-1.3.204.1/1.3.204.1</code>.<br />
<br />
We have to run <code>autogen.sh</code> in <code>vkd3d-git</code> to generate vkd3d's <code>configure</code> script<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs/vkd3d-git<br />
bash autogen.sh<br />
</syntaxhighlight><br />
<br />
Now we create a folder for the 64-bit vkd3d build<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir vkd3d64<br />
</syntaxhighlight><br />
<br />
We run the configure script in the installation folder:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd vkd3d64<br />
../vkd3d-git/configure \<br />
--host=x86_64-w64-mingw32 \<br />
--prefix="$HOME/wine-dirs/vkd3d64-prefix" \<br />
WIDL="$HOME/wine-dirs/wine64p/tools/widl/widl" \<br />
VULKAN_LIBS="-L$HOME/wine-dirs/wine64p/dlls/vulkan-1/" \<br />
CPPFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include" \<br />
LDFLAGS="-static-libgcc"<br />
</syntaxhighlight><br />
<br />
* <code>--host=x86_64-w64-mingw32</code> indicates that we want to cross-compile the programs and libraries using the 64-bit MinGW compiler.<br />
* <code>--prefix="$HOME/wine-dirs/vkd3d64-prefix"</code> is used to set this build's installation directory. In this case, we will create a new folder inside <code>wine-dirs</code>. We have to keep in mind that the other programs will expect the vkd3d libraries to be in this directory at run-time.<br />
* We set the <code>WIDL</code> and <code>VULKAN_LIBS</code> variables to point to our provisional 64-bit wine's WIDL and vulkan-1 DLL, respectively.<br />
* We use <code>CPPFLAGS</code> so that the compiler knows to search in the <code>vulkan-sdk</code> folder for the vulkan headers (<code>-I</code> flag).<br />
* We use <code>LDFLAGS="-static-libgcc"</code> because MinGW gcc depends on <code>libgcc_s_sjlj-1.dll</code>; this links a static version. Otherwise we should add the right path using the <code>-L</code> flag.<br />
<br />
<!-- I had a bug similar to: https://bugzilla.redhat.com/show\_bug.cgi?id=977039 --><br />
<br />
Then we run<br />
<br />
<syntaxhighlight lang="bash"><br />
make<br />
</syntaxhighlight><br />
<br />
And if the build succeeds, then we run<br />
<br />
<syntaxhighlight lang="bash"><br />
make install<br />
</syntaxhighlight><br />
<br />
to install 64-bit vkd3d in <code>$HOME/wine-dirs/vkd3d64-prefix</code>.<br />
<br />
== Build 64-bit wine ==<br />
<br />
Now with the 64-bit <code>vkd3d</code> installation, we can compile a 64-bit Wine linked to it.<br />
<br />
We proceed creating a new folder:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine64<br />
</syntaxhighlight><br />
<br />
We run the Wine <code>configure</code> script again, but now specifying the parameters to link Wine to the 64-bit vkd3d prefix we just created. We will also need to include the vulkan headers:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine64<br />
../wine-git/configure --enable-win64 \<br />
CC='ccache gcc' CROSSCC='ccache x86_64-w64-mingw32-gcc' \<br />
--with-system-dllpath="$HOME/wine-dirs/vkd3d64-prefix/bin:<mingw 64-bit gcc dynamic dependencies>" \<br />
VKD3D_PE_CFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include -I$HOME/wine-dirs/vkd3d64-prefix/include/vkd3d" \<br />
VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d64-prefix/lib -lvkd3d -lvkd3d-shader"<br />
</syntaxhighlight><br />
<br />
* We use <code>--with-system-dllpath</code> so that wine knows to search our vkd3d prefix for the vkd3d DLLs, and also to search MinGW-w64's gcc Win64 dynamic dependencies. <!--<br />
--> <p> Notice that both directories are separated with a colon. </p> <!--<br />
--> <p> {{Warning}} You need to replace <code><mingw 64-bit gcc dynamic dependencies></code> with the right directory. In Ubuntu, the directory is <code>/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32</code> and the dependencies are provided by the <code>gcc-mingw-w64-x86-64</code> package. </p><br />
* We set <code>VKD3D_PE_CFLAGS</code> and <code>VKD3D_PE_LIBS</code> to indicate that we will use a custom version of vkd3d. We use <code>VKD3D_PE_CFLAGS</code> to include the vulkan headers and the vkd3d headers and <code>VKD3D_PE_LIBS</code> to load vkd3d's dynamic libraries.<br />
<br />
<br />
{{Info}} If you get the following message around the last lines:<br />
<br />
<syntaxhighlight lang="bash"><br />
configure: libvkd3d 64-bit MinGW development files not found; using bundled version.<br />
</syntaxhighlight><br />
<br />
Wine was '''not''' correctly linked to your custom version of vkd3d. Check the <code>config.log</code>.<br />
<br />
Then we build Wine again:<br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
== Build a provisional 32-bit Wine ==<br />
<br />
Now that we have a working 64-bit Wine we need to build a 32-bit Wine and link it to the 64-bit Wine in order to support 64-bit applications. For that purpose, we need to repeat the previous steps but now with a 32-bit Wine build. Starting by creating a provisional 32-bit Wine installation in order to compile a 32-bit vkd3d.<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine32p<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine32p<br />
../wine-git/configure --disable-tests \<br />
CC='ccache gcc' CROSSCC='ccache i686-w64-mingw32-gcc'<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
== Build a 32-bit vkd3d installation ==<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir vkd3d32<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
cd vkd3d32<br />
../vkd3d-git/configure \<br />
--host=i686-w64-mingw32 \<br />
--prefix="$HOME/wine-dirs/vkd3d32-prefix" \<br />
WIDL="$HOME/wine-dirs/wine32p/tools/widl/widl" \<br />
VULKAN_LIBS="-L$HOME/wine-dirs/wine32p/dlls/vulkan-1/" \<br />
CPPFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include" \<br />
LDFLAGS="-static-libgcc"<br />
</syntaxhighlight><br />
<br />
* We now use <code>--host=i686-w64-mingw32</code> to indicate that we will use the 32-bit MinGW compiler.<br />
* We are changing the prefix so that this 32-bit vkd3d is installed in the <code>vkd3d32-prefix</code> folder instead of <code>vkd3d64-prefix</code>.<br />
* We also will link to the WIDL and vulkan-1 DLLs inside our 32-bit provisional wine.<br />
* We can still use the vulkan headers in our 64-bit vulkan-sdk.<br />
<br />
<br />
We then run:<br />
<br />
<syntaxhighlight lang="bash"><br />
make<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
make install<br />
</syntaxhighlight><br />
<br />
== Build 32-bit Wine ==<br />
<br />
We can now build our 32-bit Wine, linking it to our 32-bit vkd3d.<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine32<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine32<br />
../wine-git/configure --with-wine64=../wine64/ \<br />
CC='ccache gcc' CROSSCC='ccache i686-w64-mingw32-gcc' \<br />
--with-system-dllpath="$HOME/wine-dirs/vkd3d32-prefix/bin:<mingw 32-bit dynamic dependencies>" \<br />
VKD3D_PE_CFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include -I$HOME/wine-dirs/vkd3d32-prefix/include/vkd3d" \<br />
VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d32-prefix/lib -lvkd3d -lvkd3d-shader"<br />
</syntaxhighlight><br />
<br />
* We now point <code>--with-system-dllpath</code> and <code>VKD3D_PE_LIBS</code> to the directories inside <code>vkd3d32-prefix</code>. <!--<br />
--> <p> {{Warning}} You also have to replace <code><mingw 32-bit dynamic dependencies></code> with MinGW-w64's gcc Win32 dynamic dependencies' directory now. In Ubuntu this directory is <code>/usr/lib/gcc/i686-w64-mingw32/9.3-win32</code> and the dependencies are provided by the <code>gcc-mingw-w64-i686</code> package. </p><br />
<br />
<br />
Finally, build Wine:<br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
= Updating your build =<br />
<br />
If you want to update either wine or vkd3d's source code, we can execute the following commands in order. <code>ccache</code> should help reducing the compilations times.<br />
<br />
<syntaxhighlight lang="bash"><br />
# Recompile 64-bit vkd3d<br />
cd $HOME/wine-dirs/vkd3d64;<br />
make<br />
make install<br />
<br />
# Recompile 64-bit wine<br />
cd $HOME/wine-dirs/wine64;<br />
make -j8<br />
<br />
# Recompile 32-bit vkd3d<br />
cd $HOME/wine-dirs/vkd3d32;<br />
make<br />
make install<br />
<br />
# Recompile 32-bit wine<br />
cd $HOME/wine-dirs/wine32;<br />
make -j8<br />
</syntaxhighlight><br />
<br />
{{Warning}} Sometimes, for instance if you run the <code>configure</code> script again to change the <code>--with-system-dllpath</code> argument, you have to make sure to also execute <code>make clean</code> beforehand.</div>Fcasashttps://wiki.winehq.org/index.php?title=Vkd3d&diff=3911Vkd3d2022-03-23T13:45:33Z<p>Fcasas: Added a link to Building a MinGW WoW64 Wine with a custom vkd3d build</p>
<hr />
<div>Vkd3d is a 3D graphics library built on top of Vulkan. It has an API very similar, but not identical, to Direct3D 12. Wine uses vkd3d libraries for its implementation of Direct3D 12.<br />
<br />
= Building =<br />
<br />
== Getting the vkd3d source ==<br />
<br />
You can download the Vkd3d source code as a [https://dl.winehq.org/vkd3d/source/ tarball], but if you plan to do any actual testing or developing, you'll want to use [https://source.winehq.org/git/vkd3d.git/ git].<br />
<br />
To grab the source code, just enter the following command:<br />
<br />
git clone git://source.winehq.org/git/vkd3d.git/<br />
<br />
== Compiling ==<br />
<br />
Enter the following commands:<br />
<br />
./autogen.sh<br />
./configure<br />
make<br />
<br />
See also the [https://source.winehq.org/git/vkd3d.git/blob_plain/HEAD:/README README file].<br />
<br />
In order to build 32-bit libraries:<br />
<br />
../vkd3d/configure --build=i686-pc-linux-gnu "CPPFLAGS=-m32" "LDFLAGS=-m32"<br />
<br />
== Building a MinGW WoW64 Wine with a custom vkd3d build ==<br />
<br />
If you want your Wine build to use a custom vkd3d build and make it compatible with a wider range of applications, check [[Building a MinGW WoW64 Wine with a custom vkd3d build]].<br />
<br />
== Building Wine with Direct3D 12 support ==<br />
<br />
Wine uses '''pkg-config''' to find vkd3d libraries. If vkd3d libraries are installed system-wide, the Wine configure script should find the vkd3d libraries automatically. You can also use '''PKG_CONFIG_PATH''', '''VKD3D_CFLAGS''' or '''VKD3D_LIBS''' to override '''pkg-config''' search path, C compiler flags for '''libvkd3d''', or linker flags for '''libvkd3d''', e.g.<br />
<br />
../wine-git/configure PKG_CONFIG_PATH=$HOME/src/vulkan/install/lib/pkgconfig<br />
<br />
= Debugging =<br />
<br />
== Debug output ==<br />
<br />
Vkd3d provides '''VKD3D_DEBUG''' and '''VKD3D_SHADER_DEBUG''' environment variables to control debug log messages. The debug variables can be set to one of the following debug log levels: '''none''', '''err''', '''fixme''', '''warn''', '''trace'''.<br />
<br />
See the [https://source.winehq.org/git/vkd3d.git/blob_plain/HEAD:/README README file] for description of all debug environment variables.<br />
<br />
== Vulkan validation layers ==<br />
<br />
Enable validation layers in a standard way:<br />
<br />
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation<br />
<br />
You may also want to enable Vulkan debug extensions in vkd3d:<br />
<br />
VKD3D_CONFIG=vk_debug<br />
<br />
== Other tools ==<br />
<br />
* [https://renderdoc.org/ RenderDoc] is a frame-capture based debugger. It supports Vulkan and Direct3D 12.<br />
* VK_LAYER_LUNARG_api_dump is useful to dump Vulkan commands produced by libvkd3d.<br />
* [https://github.com/ValveSoftware/Fossilize Fossilize] might be useful for debugging crashes in driver shader compiler. Just capture pipelines using VK_LAYER_fossilize and use fossilize-replay to reproduce the crash.<br />
<br />
= Tests =<br />
<br />
Use the following command to run tests:<br />
make check<br />
<br />
Tests can also be run individually, for example:<br />
make tests/d3d12 && ./tests/d3d12<br />
VKD3D_TEST_FILTER=clear_render_target ./tests/d3d12<br />
<br />
To cross-compile tests for Windows run the following command:<br />
make crosstest<br />
<br />
== Shader bytecode in tests ==<br />
<br />
Some tests include compiled shader bytecode. Shader bytecode should be generated with '''/Qstrip_debug /Qstrip_reflect''' options. For example:<br />
fxc /Qstrip_debug /Qstrip_reflect /T ps_5_0 source.hlsl /Fo output.dxbc<br />
<br />
= See also =<br />
<br />
* [[vkd3d-todo]]<br />
* [[Vkd3d known issues]]<br />
<br />
[[Category:vkd3d]]</div>Fcasashttps://wiki.winehq.org/index.php?title=Building_a_MinGW_WoW64_Wine_with_a_custom_vkd3d_build&diff=3910Building a MinGW WoW64 Wine with a custom vkd3d build2022-03-23T13:31:27Z<p>Fcasas: Created page with "As of version 7.4, Wine comes with a bundled version of vkd3d. However, if you want to use a more modern version of vkd3d, apply certain patches to it, or test fixes of your..."</p>
<hr />
<div>As of version 7.4, Wine comes with a bundled version of vkd3d.<br />
<br />
However, if you want to use a more modern version of vkd3d, apply certain patches to it, or test fixes of your own, you will need Wine to work with a custom version of vkd3d.<br />
<br />
For this purpose, it is necessary to build both projects and link them correctly.<br />
<br />
Compiling a Windows on Windows (WoW) version of Wine, so that it supports both 32-bits and 64-bits Windows applications – which is often desired – adds a layer of complexity to the build process.<br />
<br />
Furthermore, you may want to use MinGW to cross-compile the Wine executables and DLLs in the Windows PE format. This is because various programs expect the on-disk DLLs to look like real PE DLLs.<br />
<br />
This guide aims to help you through that process.<br />
<br />
= Preliminaries =<br />
<br />
== Install Wine dependencies ==<br />
<br />
First, install the dependencies listed in the [[Building Wine#Satisfying Build Dependencies | Building Wine]] article.<br />
<br />
Remember to install the <code>:i386</code> version of the required packages too (if your system has multi-lib support).<br />
<br />
The '''mingw''' and '''vulkan''' packages are of particular importance.<br />
<br />
It is also recommended that you install <code>ccache</code>, as it may save us a considerable amount of time during the builds.<br />
<br />
{{Info}} If you have a system-wide installation of vkd3d, it may be good to uninstall it using <code>make uninstall</code>. To ensure that the correct version of vkd3d is linked in this tutorial.<br />
<br />
== Directory organization ==<br />
<br />
For this tutorial we will need to create several build directories and have several git repositories. For this reason, we will start by creating a common directory for them:<br />
<br />
<syntaxhighlight lang="bash"><br />
mkdir -p $HOME/wine-dirs<br />
</syntaxhighlight><br />
<br />
== Cloning <code>wine</code> and <code>vkd3d</code> repositories ==<br />
<br />
First, we clone the <code>wine</code> repository if we haven't already:<br />
<br />
<syntaxhighlight lang="bash"><br />
git clone git://source.winehq.org/git/wine.git $HOME/wine-dirs/wine-git<br />
</syntaxhighlight><br />
<br />
We also need to clone <code>vkd3d</code> repository if we haven't already:<br />
<br />
<syntaxhighlight lang="bash"><br />
git clone git://source.winehq.org/git/vkd3d.git $HOME/wine-dirs/vkd3d-git<br />
</syntaxhighlight><br />
<br />
In case you already have these repositories somewhere else, you can create symbolic links inside <code>wine-dirs</code> instead:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
ln -s <relative-path-to-wine-repo> wine-git<br />
ln -s <relative-path-to-vkd3d-repo> vkd3d-git<br />
</syntaxhighlight><br />
<br />
Now it is a good time to pick a particular branch or apply the desired patches to these repositories.<br />
<br />
{{Info}} At the time of writing, the upstream Wine master branch is missing a patch that makes the d3dcompiler DLL use vkd3d's HLSL compiler for <code>D3DCompile()</code> and <code>D3DCompile2()</code>.<br />
In case you want to add this patch, execute the following commands to download this patch and apply it.<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs/wine-git<br />
wget https://source.winehq.org/patches/data/228839<br />
git am 228839<br />
</syntaxhighlight><br />
<br />
= Building =<br />
<br />
== Build a provisional 64-bit Wine ==<br />
<br />
In order to build 64-bit vkd3d we need some dependencies that can be built from the Wine repository. Namely, WIDL and the vulkan-1 DLLs.<br />
<br />
For that purpose we need first a provisional 64-bit MinGW Wine installation, so we start by creating a folder:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine64p<br />
</syntaxhighlight><br />
<br />
We run the Wine <code>configure</code> script from the installation folder<br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine64p<br />
../wine-git/configure --enable-win64 --disable-tests \<br />
CC='ccache gcc' CROSSCC='ccache x86_64-w64-mingw32-gcc'<br />
</syntaxhighlight><br />
<br />
Note that we use <code>CROSSCC=</code> to indicate the compiler used for cross-compilation, in this case we need the 64-bit mingw32 compiler. We prepend <code>ccache </code> which works as a wrapper for the compiler. The same is done for the regular C compiler, <code>gcc</code>, passed with the <code>CC=</code> variable.<br />
<br />
Since this is just a provisional build of wine, we use <code>--disable-tests</code> to speed up the compilation times.<br />
<br />
Note that to know about other parameters for the <code>configure</code> script we can use:<br />
<br />
<syntaxhighlight lang="bash"><br />
../wine-git/configure --help<br />
</syntaxhighlight><br />
<br />
Also, if something from the configure command fails, it is useful to search in <code>config.log</code> for the line that contains the pertinent error, and the lines before and after it.<br />
<br />
Once the configure script has finished, we build Wine. We can pass <code>-j<n></code> to use <code><n></code> threads.<br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
== Build a 64-bit vkd3d installation ==<br />
<br />
Now we need to do the 64-bit vkd3d build. For that purpose we will also need the Vulkan headers.<br />
One way of getting them is downloading the [https://vulkan.lunarg.com Vulkan SDK].<br />
<br />
Alternativelly, you can get them from the official [https://github.com/KhronosGroup/Vulkan-Headers Vulkan-Headers] repository. Similarly for the [https://github.com/KhronosGroup/SPIRV-Headers SPIRV-Headers] if you want to build with <code>--with-spirv-tools</code>.<br />
<br />
Assuming you downloaded and extracted the SDK, move it to the common directory:<br />
<br />
<syntaxhighlight lang="bash"><br />
mv <vulkan sdk path> $HOME/wine-dirs/vulkan-sdk<br />
</syntaxhighlight><br />
<br />
You must change the first argument of the <code>mv</code> command depending on where you downloaded and extracted the SDK. e.g. <code>~/Downloads/vulkansdk-linux-x86_64-1.3.204.1/1.3.204.1</code>.<br />
<br />
We have to run <code>autogen.sh</code> in <code>vkd3d-git</code> to generate vkd3d's <code>configure</code> script<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs/vkd3d-git<br />
bash autogen.sh<br />
</syntaxhighlight><br />
<br />
Now we create a folder for the 64-bit vkd3d build<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir vkd3d64<br />
</syntaxhighlight><br />
<br />
We run the configure script in the installation folder:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd vkd3d64<br />
../vkd3d-git/configure \<br />
--host=x86_64-w64-mingw32 \<br />
--prefix="$HOME/wine-dirs/vkd3d64-prefix" \<br />
WIDL="$HOME/wine-dirs/wine64p/tools/widl/widl" \<br />
VULKAN_LIBS="-L$HOME/wine-dirs/wine64p/dlls/vulkan-1/" \<br />
CPPFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include" \<br />
LDFLAGS="-static-libgcc"<br />
</syntaxhighlight><br />
<br />
* <code>--host=x86_64-w64-mingw32</code> indicates that we want to cross-compile the programs and libraries using the 64-bit MinGW compiler.<br />
* <code>--prefix="$HOME/wine-dirs/vkd3d64-prefix"</code> is used to set this build's installation directory. In this case, we will create a new folder inside <code>wine-dirs</code>. We have to keep in mind that the other programs will expect the vkd3d libraries to be in this directory at run-time.<br />
* We set the <code>WIDL</code> and <code>VULKAN_LIBS</code> variables to point to our provisional 64-bit wine's WIDL and vulkan-1 DLL, respectively.<br />
* We use <code>CPPFLAGS</code> so that the compiler knows to search in the <code>vulkan-sdk</code> folder for the vulkan headers (<code>-I</code> flag).<br />
* We use <code>LDFLAGS="-static-libgcc"</code> because MinGW gcc depends on <code>libgcc_s_sjlj-1.dll</code>; this links a static version. Otherwise we should add the right path using the <code>-L</code> flag.<br />
<br />
<!-- I had a bug similar to: https://bugzilla.redhat.com/show\_bug.cgi?id=977039 --><br />
<br />
Then we run<br />
<br />
<syntaxhighlight lang="bash"><br />
make<br />
</syntaxhighlight><br />
<br />
And if the build succeeds, then we run<br />
<br />
<syntaxhighlight lang="bash"><br />
make install<br />
</syntaxhighlight><br />
<br />
to install 64-bit vkd3d in <code>$HOME/wine-dirs/vkd3d64-prefix</code>.<br />
<br />
== Build 64-bit wine ==<br />
<br />
Now with the 64-bit <code>vkd3d</code> installation, we can compile a 64-bit Wine linked to it.<br />
<br />
We proceed creating a new folder:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine64<br />
</syntaxhighlight><br />
<br />
We run the Wine <code>configure</code> script again, but now specifying the parameters to link Wine to the 64-bit vkd3d prefix we just created. We will also need to include the vulkan headers:<br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine64<br />
../wine-git/configure --enable-win64 \<br />
CC='ccache gcc' CROSSCC='ccache x86_64-w64-mingw32-gcc' \<br />
--with-system-dllpath="$HOME/wine-dirs/vkd3d64-prefix/bin:<mingw 64-bit gcc dynamic dependencies>" \<br />
VKD3D_PE_CFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include -I$HOME/wine-dirs/vkd3d64-prefix/include/vkd3d" \<br />
VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d64-prefix/lib -lvkd3d -lvkd3d-shader"<br />
</syntaxhighlight><br />
<br />
* We use <code>--with-system-dllpath</code> so that wine knows to search our vkd3d prefix for the vkd3d DLLs, and also to search MinGW-w64's gcc Win64 dynamic dependencies. <!--<br />
--> <p> Notice that both directories are separated with a colon. </p> <!--<br />
--> <p> {{Warning}} You need to replace <code><mingw 64-bit gcc dynamic dependencies></code> with the right directory. In Ubuntu, the directory is <code>/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32</code> and the dependencies are provided by the <code>gcc-mingw-w64-x86-64</code> package. </p><br />
* We set <code>VKD3D_PE_CFLAGS</code> and <code>VKD3D_PE_LIBS</code> to indicate that we will use a custom version of vkd3d. We use <code>VKD3D_PE_CFLAGS</code> to include the vulkan headers and the vkd3d headers and <code>VKD3D_PE_LIBS</code> to load vkd3d's dynamic libraries.<br />
<br />
<br />
{{Info}} If you get the following message around the last lines:<br />
<br />
<syntaxhighlight lang="bash"><br />
configure: libvkd3d 64-bit MinGW development files not found; using bundled version.<br />
</syntaxhighlight><br />
<br />
Wine was '''not''' correctly linked to your custom version of vkd3d. Check the <code>config.log</code>.<br />
<br />
Then we build Wine again:<br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
== Build a provisional 32-bit Wine ==<br />
<br />
Now that we have a working 64-bit Wine we need to build a 32-bit Wine and link it to the 64-bit Wine in order to support 64-bit applications. For that purpose, we need to repeat the previous steps but now with a 32-bit Wine build. Starting by creating a provisional 32-bit Wine installation in order to compile a 32-bit vkd3d.<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine32p<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine32p<br />
../wine-git/configure --disable-tests \<br />
CC='ccache gcc' CROSSCC='ccache i686-w64-mingw32-gcc'<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
== Build a 32-bit vkd3d installation ==<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir vkd3d32<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
cd vkd3d32<br />
../vkd3d-git/configure \<br />
--host=i686-w64-mingw32 \<br />
--prefix="$HOME/wine-dirs/vkd3d32-prefix" \<br />
WIDL="$HOME/wine-dirs/wine32p/tools/widl/widl" \<br />
VULKAN_LIBS="-L$HOME/wine-dirs/wine32p/dlls/vulkan-1/" \<br />
CPPFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include" \<br />
LDFLAGS="-static-libgcc"<br />
</syntaxhighlight><br />
<br />
* We now use <code>--host=i686-w64-mingw32</code> to indicate that we will use the 32-bit MinGW compiler.<br />
* We are changing the prefix so that this 32-bit vkd3d is installed in the <code>vkd3d32-prefix</code> folder instead of <code>vkd3d64-prefix</code>.<br />
* We also will link to the WIDL and vulkan-1 DLLs inside our 32-bit provisional wine.<br />
* We can still use the vulkan headers in our 64-bit vulkan-sdk.<br />
<br />
<br />
We then run:<br />
<br />
<syntaxhighlight lang="bash"><br />
make<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
make install<br />
</syntaxhighlight><br />
<br />
== Build 32-bit Wine ==<br />
<br />
We can now build our 32-bit Wine, linking it to our 32-bit vkd3d.<br />
<br />
<syntaxhighlight lang="bash"><br />
cd $HOME/wine-dirs<br />
mkdir wine32<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="bash"><br />
cd wine32<br />
../wine-git/configure --with-wine64=../wine64/ \<br />
CC='ccache gcc' CROSSCC='ccache i686-w64-mingw32-gcc' \<br />
--with-system-dllpath="$HOME/wine-dirs/vkd3d32-prefix/bin:<mingw 32-bit dynamic dependencies>" \<br />
VKD3D_PE_CFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include -I$HOME/wine-dirs/vkd3d32-prefix/include/vkd3d" \<br />
VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d32-prefix/lib -lvkd3d -lvkd3d-shader"<br />
</syntaxhighlight><br />
<br />
* We now point <code>--with-system-dllpath</code> and <code>VKD3D_PE_LIBS</code> to the directories inside <code>vkd3d32-prefix</code>. <!--<br />
--> <p> {{Warning}} You also have to replace <code><mingw 32-bit dynamic dependencies></code> with MinGW-w64's gcc Win32 dynamic dependencies' directory now. In Ubuntu this directory is <code>/usr/lib/gcc/i686-w64-mingw32/9.3-win32</code> and the dependencies are provided by the <code>gcc-mingw-w64-i686</code> package. </p><br />
<br />
<br />
Finally, build Wine:<br />
<br />
<syntaxhighlight lang="bash"><br />
make -j8<br />
</syntaxhighlight><br />
<br />
= Updating your build =<br />
<br />
If you want to update either wine or vkd3d's source code, we can execute the following commands in order. <code>ccache</code> should help reducing the compilations times.<br />
<br />
<syntaxhighlight lang="bash"><br />
# Recompile 64-bit vkd3d<br />
cd $HOME/wine-dirs/vkd3d64;<br />
make<br />
make install<br />
<br />
# Recompile 64-bit wine<br />
cd $HOME/wine-dirs/wine64;<br />
make -j8<br />
<br />
# Recompile 32-bit vkd3d<br />
cd $HOME/wine-dirs/vkd3d32;<br />
make<br />
make install<br />
<br />
# Recompile 32-bit wine<br />
cd $HOME/wine-dirs/wine32;<br />
make -j8<br />
</syntaxhighlight><br />
<br />
{{Warning}} Sometimes, for instance if you change the <code>--with-system-dllpath</code> argument, you would also need to execute <code>make clean</code> before.</div>Fcasas