From 03462b25fd8e9fa43bbd900c5148be7a1ce7586a Mon Sep 17 00:00:00 2001 From: Luciano Iam Date: Fri, 30 Aug 2019 12:24:48 +0200 Subject: [PATCH] Update wscripts and guide for MinGW --- common/wscript | 6 +++ windows/README_MINGW | 115 +++++++++++++++++-------------------------- wscript | 11 ++++- 3 files changed, 59 insertions(+), 73 deletions(-) diff --git a/common/wscript b/common/wscript index afc251a2..e102a6ef 100644 --- a/common/wscript +++ b/common/wscript @@ -197,6 +197,12 @@ def build(bld): if bld.env['IS_SUN']: clientlib.env.append_value('LINKFLAGS', '-lnsl -lsocket') + if bld.env['IS_WINDOWS']: + # statically link libjack to libstdc++, some client apps like ardour come + # with a different version of libstdc++.dll that takes precedence and results + # in missing symbols during runtime + clientlib.env.append_value('LINKFLAGS', ['-static-libstdc++', '--disable-auto-import']) + if bld.variant: # if there is variant defined, we expect it to be the 32bit client lib one # we don't want to build other stuff in this variant diff --git a/windows/README_MINGW b/windows/README_MINGW index 0b9b8d50..abd91ea4 100644 --- a/windows/README_MINGW +++ b/windows/README_MINGW @@ -1,8 +1,8 @@ HOW TO COMPILE JACK USING WAF AND MINGW ======================================= -Rev. 0 - 2019-28-08 -Rev. 1 - 2019-29-08 - Ardour compatibility by statically linking libstdc++ +Rev. 0 - 2019-08-28 - First version +Rev. 1 - 2019-08-30 - Update guide to reflect patched wscripts About @@ -14,43 +14,34 @@ process across all platforms. On Windows that would involve deprecating the Code::Blocks projects and repo dependence on static Windows libraries that can become obsolete in the future (if not already). -As this is work in progress, there are a couple of missing things: +As this is work in progress, there are still a couple of missing things: - ASIO output support - Metadata support on Windows still not working -- Update waf scripts to compile JackRouter -- Update waf scripts to avoid unnecessary patching (see below) -- Lots of testing, I am neither a Windows, MinGW or JACK power user. +- Update waf scripts to include JackRouter +- Lots of testing For getting ASIO to work, PortAudio needs to be compiled against the Steinberg ASIO SDK. The prebuilt MinGW binary package for portaudio does not include ASIO -support and also probably it is not a good idea to rely on prebuilt binary -packages since the guide uses a GCC compiler that is not the default version -shipped by MinGW. It would be helpful to include a good technical explanation -and/or evidence for this statement. Some interesting information on building -PortAudio with ASIO support can be found here: +support. Some interesting information on the build process can be found here: https://app.assembla.com/wiki/show/portaudio/Notes_about_building_PortAudio_with_MinGW -Install the toolchain - MSYS2 ------------------------------ +Creating the development environment +------------------------------------ -The installer is called msys2-x86_64-{version}.exe and can be found at -https://www.msys2.org/ +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 with -administrator privileges. Running from a regular user causes compilation issues -for some dependencies because of the inability to fork processes. For example -libtool will fail for portaudio. +- Open "MSYS2 MinGW 64-bit terminal" from the MSYS2 start menu shortcuts -- Upgrade MSYS2 installation. Running the following command might require -closing the MSYS2 window at a certain point and then restarting (do not forget -to re-run as administrator) +- Upgrade all MSYS2 packages. Running the following command might require +closing the MSYS2 window at a certain point and then restarting pacman -Suy -- Install some packages +- Install needed packages pacman -S mingw-w64-x86_64-toolchain patch autoconf make \ gettext-devel automake libtool pkgconfig p7zip git python @@ -85,12 +76,15 @@ $ gcc --version gcc.exe (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) {version} -Install JACK depdendencies --------------------------- +Installing JACK dependencies +---------------------------- There are prebuilt MinGW binaries for all the libraries that can be installed -using the pacman package manager, but since there are many MinGW flavors it is -better idea to build from source to avoid any linker and runtime issues. +using the pacman package manager, but since we are using a compiler that is not +the default shipped version 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 @@ -101,17 +95,23 @@ MINGW_INSTALLS=mingw64 makepkg-mingw -sLf pacman -U mingw-w64-{libname}-git-{suffix}.pkg.tar.xz Repeat procedure for each library replacing {libname} with the appropriate name -and {suffix} with whatever the above process created. For example: -mingw-w64-x86_64-libtre-git-r128.6fb7206-2-any.pkg.tar.xz +and {suffix} with whatever the above process created. db -libtre portaudio libsndfile libsamplerate Some libraries like libsndfile and libsamplerate will ask for installing extra -dependencies, it is ok to do so. +dependencies, it is ok to do so. The following need to be built in order: + +libtre +libsystre + +libsystre is a wrapper around libtre that allows including later. +Before building it adjust the includes path, you can unset afterwards. + +export C_INCLUDE_PATH=/mingw64/include Compile JACK @@ -119,17 +119,13 @@ Compile JACK - Clone repo git clone https://github.com/jackaudio/jack2 -cd jack2 - -- (Needs better solution) Allow gcc to find regex.h and db.h, pkgconfig is not -of much help here: -export CPATH=$CPATH:/mingw64/include/tre:/mingw64/include +- Build and install -- (Needs wscript solution) disable check for db.h otherwise waf will configure -without metadata support. Edit wscript and comment out the following line: +cd jack2 +./waf configure --prefix=/opt/jack --db=no && ./waf -p install -db.check(header_name='db.h') +The resulting files can be found at /c/opt/jack/bin, or c:\msys64\opt\jack\bin Note that currently metadata support is not working on Windows and probably involves patching common/JackMetadata.cpp: @@ -138,35 +134,8 @@ server\__db.001: No such file or directory Creating the mentioned "server" directory results in: Cannot open metadata DB at server\metadata.db: No such file or directory -So for now it is recommended to pass --db=no to waf configure or leaving wscript -intact, so the db.check() call fails and DB ends disabled. Leaving DB enabled -will make jackd behave erratically or crash. - -- (Needs wscript solution) define missing constants, this can be done by editing -build/config.h: - -#define ADDON_DIR "jack" -#define PRIu64 "llu" (unsigned long long is 64bits wide on MinGW-W64) -//#define HAVE_ASIO 1 (do not use this yet) - -Do not forget to re-add these lines after every waf configure run. As stated -above, a final solution should come from wscript. - -- Link libjack to libstdc++ statically. Some client apps like Ardour already -ship with a libstdc++-6.dll library that will take precedence, resulting in -missing symbols during runtime load of libjack.dll. Add the following link flags -to common/wscript @ ~200: - -if bld.env['IS_WINDOWS']: - clientlib.env.append_value('LINKFLAGS', ['-static-libstdc++', '--disable-auto-import']) - -- Finally build and install - -./waf configure --prefix=/opt/jack --db=no -./waf -./waf install - -The resulting files can be found at /c/opt/jack/bin, or c:\msys64\opt\jack\bin +So for now it is recommended to pass --db=no to waf configure. Leaving metadata +support enabled will make jackd behave erratically or crash. Running and distributing @@ -179,10 +148,11 @@ libstdc++-6.dll libgcc_s_sjlj-1.dll libwinpthread-1.dll libtre-5.dll +libsystre-0.dll libdb-6.0.dll libsndfile-1.dll libportaudio-2.dll -libsamplerate-0.dll (audioadapter, jack_netone, netadapter) +libsamplerate-0.dll To enable JACK-enabled applications talk to the freshly built server, copy the following DLLs to c:\windows (that is what the current official 1.9.11 installer @@ -193,12 +163,13 @@ libjack-0.dll (rename to libjack64.dll) libgcc_s_sjlj-1.dll libwinpthread-1.dll libtre-5.dll +libsystre-0.dll Tested working clients: QJackCtl Ardour Bitwig Studio -JackRouter.dll +JackRouter Example of starting the JACK server including MIDI support for a Focusrite USB audio device using WASAPI: @@ -207,7 +178,9 @@ jackd -R -X winmme -d portaudio -p 1024 -r 48000 ^ Lower latencies cause xruns, even with official JACK binaries + WASAPI -Handy development tools and links: + +Development tools and links +--------------------------- http://www.dependencywalker.com/ https://docs.microsoft.com/en-us/sysinternals/downloads/procmon diff --git a/wscript b/wscript index f73a16d6..09322c0c 100644 --- a/wscript +++ b/wscript @@ -211,6 +211,8 @@ def configure(conf): if conf.env['IS_WINDOWS']: conf.env.append_unique('CCDEFINES', '_POSIX') conf.env.append_unique('CXXDEFINES', '_POSIX') + if Options.options.platform == 'msys': + conf.env.append_value('INCLUDES', ['/mingw64/include']) conf.env.append_unique('CXXFLAGS', '-Wall') conf.env.append_unique('CXXFLAGS', '-std=gnu++11') @@ -361,8 +363,13 @@ def configure(conf): # existing install paths that use ADDON_DIR rather than have to # have special cases for windows each time. conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack' - # don't define ADDON_DIR in config.h, use the default 'jack' defined in - # windows/JackPlatformPlug_os.h + if Options.options.platform == 'msys': + conf.define('ADDON_DIR', 'jack') + conf.define('__STDC_FORMAT_MACROS', 1) # for PRIu64 + else: + # don't define ADDON_DIR in config.h, use the default 'jack' defined in + # windows/JackPlatformPlug_os.h + pass else: conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')) conf.define('ADDON_DIR', conf.env['ADDON_DIR'])