File: README_MINGW

package info (click to toggle)
jackd2 1.9.17~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,524 kB
  • sloc: cpp: 48,028; ansic: 30,427; python: 12,448; sh: 270; makefile: 60
file content (287 lines) | stat: -rw-r--r-- 10,567 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
HOW TO COMPILE JACK ON WINDOWS/MINGW
====================================

Rev. 1 - 2019-09-01 - First version
Rev. 2 - 2019-09-18 - Include contributions from @Schroedingers-Cat
Rev. 3 - 2019-12-14 - Include contributions from @Schroedingers-Cat
Rev. 4 - 2020-11-27 - Rename, update intro and JackRouter build instructions


Introduction
------------

This guide was originally called "How to compile JACK using WAF and MinGW"
and later renamed to "How to compile JACK on Windows/MinGW" to avoid confusion
with the official way of building JACK for Windows, which is cross-compiling
on Linux. That should be considered the only officially supported method now.

Latest binary releases can be found here: https://jackaudio.org/downloads/
JackRouter here: https://github.com/jackaudio/jack-router/tree/main/binaries

JACK is primarily targeted at Unix systems and thus the required toolchain is
Unix-centric. So the majority of the guide is actually about setting up the
required build tools. Once done, the build process itself does not differ much
from that found on other platforms.

The information here can be of interest to anyone wishing to contribute to the
development of Windows specific code in JACK, and wants to avoid double booting,
VMs, etc. That can be particularly helpful when it comes to debug or testing.



Creating the development environment
------------------------------------

This guide uses MSYS2 as the toolchain, it can be found at https://www.msys2.org/
It comes as a handy installer called msys2-x86_64-{version}.exe. Once installed:

- Open "MSYS2 MinGW 64-bit terminal" from the MSYS2 start menu shortcuts

- Upgrade base MSYS2 packages

pacman -Suy

It is possible pacman ends with the following banner:

warning: terminate MSYS2 without returning to shell and check for updates again
warning: for example close your terminal window instead of calling exit

In such case close the MSYS2 window, re-open, and run pacman -Suy again.

- Install required packages

pacman -S mingw-w64-x86_64-toolchain patch autoconf make \
gettext-devel automake libtool pkgconfig p7zip unzip git python

- Replace the GCC compiler with a version configured for SJLJ exceptions, as
instructed by the original Windows build instructions (windows/README)

Prebuilt binaries can be found at
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/

Look for "x86_64-posix-sjlj" under "MinGW-W64 GCC-{version}", the file should be
called x86_64-{version}-release-posix-sjlj-rt_v6-rev0.7z

Or just download from a direct link (GCC 8.1.0):

wget https://downloads.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z

Once downloaded:

p7zip -d x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z

That will decompress to a folder called mingw64 in the working directory.
Now replace the files from the previous mingw-w64-x86_64-toolchain package
installation:

mv /mingw64 /mingw64.bak   -> backup original
rm /mingw64                -> see explanation below
mv mingw64 /               -> sjlj toolchain

The first step results in a new file called mingw64 file being created in /. The
file is not visible to the Windows File Explorer when inspecting C:\msys64, so
it is probably an artifact and safe to delete it in the second step. Otherwise
the last mv step will fail with:

mv: cannot overwrite non-directory '/mingw64' with directory 'mingw64'

An alternate solution consists in closing the MSYS2 window and replicating the
above procedure using the File Explorer. The following assumes the toolchain 7z
file was decompressed to the home directory:

Rename C:\msys64\mingw64 to C:\msys64\mingw64.bak
Move C:\msys64\home\{username}\mingw64 to C:\msys64

Make sure gcc runs and it is the expected version:

$ gcc --version
gcc.exe (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) {version}



Preparing JACK dependencies
---------------------------

There are prebuilt MinGW binaries for all the libraries that can be installed
using the pacman package manager, but since we are using a compiler that is not
the default version shipped by MinGW, it seems better idea to build from source
to avoid any linker and runtime issues. A good technical explanation and/or
evidence for this statement is currently missing from this guide.

Fortunately there are PKGBUILD files for doing so together with a nice guide at
https://github.com/msys2/MINGW-packages

git clone https://github.com/msys2/MINGW-packages.git

Before building libraries, adjust the includes path:

export C_INCLUDE_PATH=/mingw64/include

The basic procedure for building and installing libraries is:

cd MINGW-packages/mingw-w64-{libname}
MINGW_INSTALLS=mingw64 makepkg-mingw -sLf
pacman -U mingw-w64-{libname}-{suffix}.pkg.tar.xz

Repeat the procedure for each library listed below replacing {libname} with the
appropriate name and {suffix} with whatever the above process creates. Keep the
recommended build order, for example libsamplerate depends on libsndfile, and
libsystre depends on libtre-git. libsystre is a wrapper around libtre that
allows including <regex.h> later.

Some libraries like libsndfile and libsamplerate will ask for installing extra
dependencies, it is ok to do so.

For low latency audio it is recommended to build portaudio with ASIO support, so
the Steinberg ASIO SDK should be manually downloaded beforehand. It can be found
at https://www.steinberg.net/en/company/developers.html. The waf script will
later check if the SDK is present at /opt/asiosdk

wget https://www.steinberg.net/asiosdk -O /tmp/asiosdk.zip
unzip /tmp/asiosdk.zip -d /tmp
mkdir /opt   <- MinGW does not create /opt during installation
mv /tmp/asiosdk_{version}_{date} /opt/asiosdk

The description file in portaudio (MINGW-packages/mingw-w64-portaudio/PKGBUILD)
needs to be patched so configure is called with the necessary flags for ASIO:

--with-asiodir=/opt/asiosdk   <- new option     
--with-winapi=wmme,directx,wasapi,vdmks,asio   <- append 'asio' to existing

Both static and shared library versions of portaudio are built. To prevent
errors while building the shared version or recompiling static, also insert the
following lines in PKGBUILD after the first make call (around line 60) and after
second make (around line 70):

find /opt/asiosdk -name "*.lo" -type f -delete
find /opt/asiosdk -name "*.o" -type f -delete

Finally here is the list of libraries to build:

db
libsndfile
libsamplerate
libtre-git
libsystre
portaudio



Compiling JACK
--------------

- Clone repo

git clone https://github.com/jackaudio/jack2

- Build and install

cd jack2
./waf configure --prefix=/opt/jack && ./waf -p install

The resulting files can be found at /c/opt/jack/bin, or C:\msys64\opt\jack\bin



Compiling JackRouter
--------------------

Source code for JackRouter is not considered part of JACK anymore so you need to
clone an additional repository:

git clone https://github.com/jackaudio/jack-router

Visual Studio with MFC support is needed to build the included JackRouter VS
project. The project was tested to successfully generate a 64bit version of
JackRouter.dll using Visual Studio 2017 and 2019. MFC support can be added from
the VS installer, by selecting Workloads/Visual C++ build tools/Visual C++ MFC
for x86 and x64 (valid for VS 2017).

Once ready, just open and build the project

win/JackRouter.sln

Notes:

- The project assumes the needed ASIO SDK is located in C:\Program Files\asiosdk
  you can simply copy the SDK from the MinGW JACK installation, i.e. from
  C:\msys64\opt to C:\Program Files
- Links against C:\Program Files\JACK2\lib\libjack64.dll.a which is the libjack
  version installed by the official installer. You will have to update that path
  so it points to the jack.dll.a created by the MinGW build instead.



Running and distributing
------------------------

!! This section is kept for historical reasons. The official JACK for Windows
build method includes the necessary steps to create a installer. !!

An automated installation process should copy files to two destinations. One for
the JACK server binary and standalone tools, and another for the client library.
The latter is needed by JACK enabled applications in order to be able to connect
to the server.

- Create a directory named C:\Program Files\Jack (can be anything else)
- Copy all files in C:\msys64\opt\jack\bin to C:\Program Files\Jack
- Copy the following DLLs from C:\msys64\mingw64\bin to C:\Program Files\Jack,
these are dependencies for the JACK server and tools:

libstdc++-6.dll
libdb-6.0.dll
libsndfile-1.dll
libsamplerate-0.dll
libportaudio-2.dll
libgcc_s_sjlj-1.dll
libwinpthread-1.dll
libtre-5.dll
libsystre-0.dll

- Copy and rename the following files from C:\msys64\opt\jack\bin to C:\Windows
to make libjack available to clients:

libjackserver-0.dll   -> libjackserver64.dll
libjack-0.dll         -> libjack64.dll

- Copy the following files from C:\msys64\mingw64\bin to C:\Windows, these are
dependencies for libjack. C:\Windows is the directory the current official JACK
1.9.11 binary installer targets, a better solution should be devised to avoid
cluttering the Windows directory:

libgcc_s_sjlj-1.dll
libwinpthread-1.dll
libtre-5.dll
libsystre-0.dll

- Copy JackRouter.dll from windows\JackRouter\Release64 to C:\Program Files\Jack
This allows non-JACK applications to connect to the server through a special
ASIO driver that routes audio to JACK instead of a physical audio device.
Also copy libjack-0.dll from C:\msys64\mingw64\bin to C:\Program Files\Jack
because JackRouter depends on libjack but will check for libjack-0.dll instead
of the system-wide libjack64.dll previously copied to C:\Windows. Once done,
JackRouter needs to be registered:

regsvr32 JackRouter.dll

Tested working clients:
Ardour
Bitwig Studio
QJackCtl
JackRouter

Example of starting the JACK server including MIDI support for a Focusrite USB
audio device using ASIO:
jackd -R -S -X winmme -d portaudio -p 32 -r 48000 -d "ASIO::Focusrite USB ASIO"



Development tools and links
---------------------------

http://www.dependencywalker.com/
https://docs.microsoft.com/en-us/sysinternals/downloads/procmon
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags
https://blogs.msdn.microsoft.com/junfeng/2006/11/20/debugging-loadlibrary-failures/
https://stackoverflow.com/questions/15852677/static-and-dynamic-shared-linking-with-mingw
https://github.com/EddieRingle/portaudio/blob/master/src/hostapi/asio/ASIO-README.txt