From e4f698ecbe12733d943080b39e8480ff400da10f Mon Sep 17 00:00:00 2001 From: Alex Birch Date: Sun, 17 Jun 2018 14:23:58 +0100 Subject: [PATCH] fix instructions for building Windows --- Builds/VisualStudio2017/build-windows.md | 225 ++++++++++------------- 1 file changed, 101 insertions(+), 124 deletions(-) diff --git a/Builds/VisualStudio2017/build-windows.md b/Builds/VisualStudio2017/build-windows.md index a15effc..934f3c0 100644 --- a/Builds/VisualStudio2017/build-windows.md +++ b/Builds/VisualStudio2017/build-windows.md @@ -1,37 +1,63 @@ -Glossary: +A lot of thrashing was involved. -https://github.com/msys2/msys2/wiki/How-does-MSYS2-differ-from-Cygwin +So first I'll list the steps that I _know_ are necessary. +Then after that I'll list the steps which were problem unnecessary. -``` -Cygwin: Gives you application support for POSIX compatible API, build and run environment. Useful when you have a native POSIX application you want to compile and run on a windows box. +# Definitely necessary -MSYS2: API's and build environment. This is useful when you have something like a library you want to use that requires autotools or has a complicated build system. - -MinGW: POSIX API. Useful if you want to compile, or especially cross compile using gcc, use POSIX api's and have access to unix command line tools. -``` - - -1) Install Visual Studio Community: +## Install Visual Studio Community: https://www.visualstudio.com/ -2) Configure Visual Studio build environment +## Install [VST3 Audio Plug-Ins SDK](https://www.steinberg.net/en/company/developers.html) -https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC#Settingtheenvironment +Such that this folder exists: -Sets source and target architecture to x64: - -```cmd -"C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 +``` +C:\SDKs\VST_SDK\VST3_SDK ``` -3) Clone [fluidsynth](https://github.com/FluidSynth/fluidsynth) repository: +## Install JUCE framework + +https://shop.juce.com/get-juce + +JUCE should be installed to `C:\\Juce` + +_Note: the only thing we actually need from here is `C:\Juce\modules`. I've copied that into the repository now, so soon I'll be able to make that step skippable._ + +## That's all. Probably. + +Well, unless you're also interested in the Setup project: + +## Configure "Setup" project + +This is project constructs a .exe and .msi installer (i.e. for distributing the synth). + +### Install support for Visual Studio Setup projects + +https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MicrosoftVisualStudio2017InstallerProjects + +### Fix unrecoverable build error + +Register MergeMod.dll + +https://stackoverflow.com/questions/42624572/unrecoverable-build-error-whilst-trying-to-build-setup-on-vs2015 + +If you encounter "Unrecoverable build error" when building juicysfplugin's setup.exe installer, you need to open an administrator prompt and register MergeMod.dll: ```bash -git clone git@github.com:FluidSynth/fluidsynth.git +regsvr32 "C:\Program Files (x86)\Common Files\Microsoft Shared\MSI Tools\MergeMod.dll" ``` -4) Install msys2 toolchain: +You may also need to run Visual Studio as Adminstrator. + +# Necessary for changing the dependencies + +If you want to build against a newer version of fluidsynth, you'll need libfluidsynth.dll and friends. + +The way I originally got these was from MSYS2's MinGW repository. + +## Install msys2 toolchain (x86_64): http://www.msys2.org/ @@ -40,7 +66,7 @@ http://www.msys2.org/ > provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains > features a package management system to provide easy installation of packages, Pacman -5) Grab latest package definitions: +## Grab latest package definitions: Press the Start key to search for and launch an MSYS2 command prompt. Named `MSYS2 MinGW 64-bit`. @@ -54,7 +80,7 @@ It may ask you to close the terminal and run update one more time: pacman -Su ``` -6) install libfluidsynth.dll: +## Install libfluidsynth.dll: https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-fluidsynth/PKGBUILD @@ -62,88 +88,40 @@ https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-fluidsynth/PKGBU pacman -S --needed mingw64/mingw-w64-x86_64-fluidsynth ``` -``` -$ pacman -S --needed mingw64/mingw-w64-x86_64-fluidsynth -resolving dependencies... -looking for conflicting packages... +## Learn about how to make changes to PKGBUILD -Packages (36) mingw-w64-x86_64-bzip2-1.0.6-6 mingw-w64-x86_64-ca-certificates-20170211-2 - mingw-w64-x86_64-expat-2.2.5-1 mingw-w64-x86_64-flac-1.3.2-1 mingw-w64-x86_64-gcc-libs-7.3.0-2 - mingw-w64-x86_64-gettext-0.19.8.1-4 mingw-w64-x86_64-glib2-2.56.1-2 mingw-w64-x86_64-gmp-6.1.2-1 - mingw-w64-x86_64-libffi-3.2.1-4 mingw-w64-x86_64-libiconv-1.15-3 mingw-w64-x86_64-libogg-1.3.3-1 - mingw-w64-x86_64-libsndfile-1.0.28-1 mingw-w64-x86_64-libsystre-1.0.1-4 mingw-w64-x86_64-libtasn1-4.13-1 - mingw-w64-x86_64-libtre-git-r128.6fb7206-2 mingw-w64-x86_64-libvorbis-1.3.6-1 - mingw-w64-x86_64-libwinpthread-git-6.0.0.5134.2416de71-1 mingw-w64-x86_64-mpc-1.1.0-1 - mingw-w64-x86_64-mpfr-4.0.1-1 mingw-w64-x86_64-ncurses-6.1.20180526-1 mingw-w64-x86_64-openssl-1.0.2.o-1 - mingw-w64-x86_64-p11-kit-0.23.12-1 mingw-w64-x86_64-pcre-8.42-1 - mingw-w64-x86_64-portaudio-190600_20161030-3 mingw-w64-x86_64-python3-3.6.5-1 - mingw-w64-x86_64-readline-7.0.005-1 mingw-w64-x86_64-speex-1.2.0-1 mingw-w64-x86_64-speexdsp-1.2rc3-3 - mingw-w64-x86_64-sqlite3-3.24.0-1 mingw-w64-x86_64-tcl-8.6.8-1 mingw-w64-x86_64-termcap-1.3.1-3 - mingw-w64-x86_64-tk-8.6.8-1 mingw-w64-x86_64-wineditline-2.205-1 mingw-w64-x86_64-xz-5.2.4-1 - mingw-w64-x86_64-zlib-1.2.11-1 mingw-w64-x86_64-fluidsynth-1.1.11-1 +If you want to change compile flags on the [fluidsynth package](https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-fluidsynth/PKGBUILD), you'll need to clone the MINGW-packages repository, edit `mingw-w64-fluidsynth/PKGBUILD`, and build with `makepkg-mingw -sCLf`. -Total Download Size: 40.77 MiB -Total Installed Size: 254.59 MiB +https://github.com/msys2/msys2/wiki/Creating-Packages#re-building-a-package + +```bash +git clone "https://github.com/Alexpux/MINGW-packages" +cd MINGW-packages/mingw-w64-fluidsynth +makepkg-mingw -sCLf +pacman -U mingw-w64-*-fluidsynth-*-any.pkg.tar.xz ``` +## Learn about dynamic linking + +You can use `ldd` to check where a dll looks for its dependencies: + ``` -alexb@DESKTOP-JE77PJ2 MSYS ~ $ ldd /mingw64/bin/libfluidsynth-1.dll - ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffcc2030000) - KERNEL32.DLL => /c/WINDOWS/System32/KERNEL32.DLL (0x7ffcc0ca0000) - KERNELBASE.dll => /c/WINDOWS/System32/KERNELBASE.dll (0x7ffcbe740000) - apphelp.dll => /c/WINDOWS/SYSTEM32/apphelp.dll (0x7ffcbc400000) - msvcrt.dll => /c/WINDOWS/System32/msvcrt.dll (0x7ffcc0d60000) - DSOUND.dll => /c/WINDOWS/SYSTEM32/DSOUND.dll (0x7ffc9ad20000) - USER32.dll => /c/WINDOWS/System32/USER32.dll (0x7ffcc1590000) - win32u.dll => /c/WINDOWS/System32/win32u.dll (0x7ffcbe9c0000) - advapi32.dll => /c/WINDOWS/System32/advapi32.dll (0x7ffcc11e0000) - GDI32.dll => /c/WINDOWS/System32/GDI32.dll (0x7ffcc1320000) - sechost.dll => /c/WINDOWS/System32/sechost.dll (0x7ffcc1ea0000) - RPCRT4.dll => /c/WINDOWS/System32/RPCRT4.dll (0x7ffcc1350000) - gdi32full.dll => /c/WINDOWS/System32/gdi32full.dll (0x7ffcbf320000) - msvcp_win.dll => /c/WINDOWS/System32/msvcp_win.dll (0x7ffcbe9e0000) - ucrtbase.dll => /c/WINDOWS/System32/ucrtbase.dll (0x7ffcbe640000) - powrprof.dll => /c/WINDOWS/System32/powrprof.dll (0x7ffcbe390000) - combase.dll => /c/WINDOWS/System32/combase.dll (0x7ffcc1720000) - WS2_32.dll => /c/WINDOWS/System32/WS2_32.dll (0x7ffcc0c30000) - WINMM.dll => /c/WINDOWS/SYSTEM32/WINMM.dll (0x7ffcbc1c0000) - libglib-2.0-0.dll => /mingw64/bin/libglib-2.0-0.dll (0x685c0000) - libportaudio-2.dll => /mingw64/bin/libportaudio-2.dll (0x632c0000) - ole32.dll => /c/WINDOWS/System32/ole32.dll (0x7ffcbf690000) - ??? => ??? (0xdd0000) - libreadline7.dll => /mingw64/bin/libreadline7.dll (0x6e780000) - SETUPAPI.dll => /c/WINDOWS/System32/SETUPAPI.dll (0x7ffcc1a50000) - SHELL32.dll => /c/WINDOWS/System32/SHELL32.dll (0x7ffcbf7f0000) - cfgmgr32.dll => /c/WINDOWS/System32/cfgmgr32.dll (0x7ffcbe5f0000) libsndfile-1.dll => /mingw64/bin/libsndfile-1.dll (0x70440000) - shcore.dll => /c/WINDOWS/System32/shcore.dll (0x7ffcbf560000) - winmmbase.dll => /c/WINDOWS/SYSTEM32/winmmbase.dll (0x7ffcbbd70000) - ??? => ??? (0x140000) - windows.storage.dll => /c/WINDOWS/System32/windows.storage.dll (0x7ffcbec10000) - libtermcap-0.dll => /mingw64/bin/libtermcap-0.dll (0x6ac40000) - shlwapi.dll => /c/WINDOWS/System32/shlwapi.dll (0x7ffcc1180000) - libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x64940000) - kernel.appcore.dll => /c/WINDOWS/System32/kernel.appcore.dll (0x7ffcbe370000) - libFLAC-8.dll => /mingw64/bin/libFLAC-8.dll (0x64080000) - libogg-0.dll => /mingw64/bin/libogg-0.dll (0x70680000) - profapi.dll => /c/WINDOWS/System32/profapi.dll (0x7ffcbe3e0000) - bcryptPrimitives.dll => /c/WINDOWS/System32/bcryptPrimitives.dll (0x7ffcbeb30000) - libspeex-1.dll => /mingw64/bin/libspeex-1.dll (0x69580000) - libvorbis-0.dll => /mingw64/bin/libvorbis-0.dll (0x6d540000) - FLTLIB.DLL => /c/WINDOWS/System32/FLTLIB.DLL (0x7ffcbe360000) - libvorbisenc-2.dll => /mingw64/bin/libvorbisenc-2.dll (0x6b680000) - libintl-8.dll => /mingw64/bin/libintl-8.dll (0x61cc0000) - libpcre-1.dll => /mingw64/bin/libpcre-1.dll (0x69140000) - libiconv-2.dll => /mingw64/bin/libiconv-2.dll (0x66000000) - IMM32.DLL => /c/WINDOWS/System32/IMM32.DLL (0x7ffcc1560000) + … ``` -6) Install CLion +# Prefer CLion? + +We don't have Windows support in our CMake project (I could add it by using Projucer to generate a CODE::Blocks exporter, but I don't want to maintain that). + +Anyway, here's my notes. + +## Install CLion https://www.jetbrains.com/clion/nextversion/ -6) Install MinGW toolchain +## Install MinGW toolchain Required for CLion integration. @@ -155,7 +133,7 @@ You don't need all the packages here (like Ada, Fortran, Objective-C...), but sp pacman -S --needed mingw-w64-x86_64-toolchain ``` -7) Configure CLion +## Configure CLion Add MinGW Toolchain: @@ -163,41 +141,21 @@ Add MinGW Toolchain: C:\msys64\mingw64 ``` -8) Install [VST3 Audio Plug-Ins SDK](https://www.steinberg.net/en/company/developers.html) +# Want to use Visual Studio upon a CMake project? -Such that this folder exists: +We don't have Windows support in our CMake project (see "Prefer CLion?" section for brief explanation), but I wrote some notes on this whilst I was thrashing around. -``` -C:\SDKs\VST_SDK\VST3_SDK +## Configure Visual Studio build environment + +https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC#Settingtheenvironment + +Sets source and target architecture to x64: + +```cmd +"C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 ``` -9) Install JUCE and Projucer - -https://shop.juce.com/get-juce - -JUCE should be installed to C:\\Juce - -10) With Projucer, open juicysfplugin/juicysfplugin.jucer - -11) Register MergeMod.dll - -https://stackoverflow.com/questions/42624572/unrecoverable-build-error-whilst-trying-to-build-setup-on-vs2015 - -If you encounter "Unrecoverable build error" when building juicysfplugin's setup.exe installer, you need to open an administrator prompt and register MergeMod.dll: - -```bash -regsvr32 "C:\Program Files (x86)\Common Files\Microsoft Shared\MSI Tools\MergeMod.dll" -``` - -You may also need to run Visual Studio itself as Administrator. - - -10) Install LLVM - -https://releases.llvm.org/download.html - - -5.onsecondthoughtsdon't) Configure MSYS2 environment +## Configure MSYS2 environment Press the Start key to search for and launch an MSYS2 command prompt. Named `MSYS2 MinGW 64-bit`. @@ -212,4 +170,23 @@ Ensure that any libs or headers you wish to include are added to the path: ```bash echo 'export LIB="EXAMPLE:$LIB"' >> ~/.bashrc echo 'export INCLUDE="EXAMPLE:$INCLUDE"' >> ~/.bashrc +``` + +## Install LLVM + +I can't remember why, since this seems to be switching to a different toolchain or compiler altogether. +Maybe it was an alternative approach. + +https://releases.llvm.org/download.html + +# Glossary + +https://github.com/msys2/msys2/wiki/How-does-MSYS2-differ-from-Cygwin + +``` +Cygwin: Gives you application support for POSIX compatible API, build and run environment. Useful when you have a native POSIX application you want to compile and run on a windows box. + +MSYS2: API's and build environment. This is useful when you have something like a library you want to use that requires autotools or has a complicated build system. + +MinGW: POSIX API. Useful if you want to compile, or especially cross compile using gcc, use POSIX api's and have access to unix command line tools. ``` \ No newline at end of file