juicysfplugin/Builds/VisualStudio2017/build-windows.md

202 lines
6.5 KiB
Markdown
Raw Normal View History

2018-06-17 21:23:58 +08:00
A lot of thrashing was involved.
2018-06-17 21:23:58 +08:00
So first I'll list the steps that I _know_ are necessary.
Then after that I'll list the steps which were probably unnecessary.
2018-06-17 21:23:58 +08:00
# Definitely necessary
2018-06-17 21:23:58 +08:00
## Install Visual Studio Community:
https://www.visualstudio.com/
## Install [VST3 Audio Plug-Ins SDK](https://www.steinberg.net/en/company/developers.html)
Such that this folder exists:
2018-06-17 21:23:58 +08:00
```
C:\SDKs\VST_SDK\VST3_SDK
```
2018-06-17 21:23:58 +08:00
## Install JUCE framework
2018-06-17 21:23:58 +08:00
https://shop.juce.com/get-juce
JUCE should be installed to `C:\Juce`
2018-06-17 21:23:58 +08:00
_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._
2018-06-17 21:23:58 +08:00
## That's all. Probably.
2018-06-17 21:23:58 +08:00
Well, unless you're also interested in the Setup project:
2018-06-17 21:23:58 +08:00
## Configure "Setup" project
This is project constructs a .exe and .msi installer (i.e. for distributing the synth).
2018-06-17 21:23:58 +08:00
### 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
regsvr32 "C:\Program Files (x86)\Common Files\microsoft shared\MSI Tools\MergeMod.dll"
```
2018-06-17 21:23:58 +08:00
You may also need to run Visual Studio as Adminstrator.
You should also consider closing the solution, deleting Visual Studio's temp files (e.g. any file touched today) inside:
```
%LocalAppData%\Temp
```
...then re-openng the solution, and attempting build again.
2018-06-17 21:23:58 +08:00
# 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/
> MSYS2 is a software distro and building platform for Windows
> an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64
> 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
2018-06-17 21:23:58 +08:00
## Grab latest package definitions:
Press the Start key to search for and launch an MSYS2 command prompt. Named `MSYS2 MinGW 64-bit`.
```
pacman -Syu
```
It may ask you to close the terminal and run update one more time:
```
pacman -Su
```
2018-06-17 21:23:58 +08:00
## Install libfluidsynth.dll:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-fluidsynth/PKGBUILD
```
pacman -S --needed mingw64/mingw-w64-x86_64-fluidsynth
```
2018-06-17 21:23:58 +08:00
## Learn about how to make changes to PKGBUILD
2018-06-17 21:23:58 +08:00
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`.
2018-06-17 21:23:58 +08:00
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
```
2018-06-17 21:23:58 +08:00
## Learn about dynamic linking
You can use `ldd` to check where a dll looks for its dependencies:
```
$ ldd /mingw64/bin/libfluidsynth-1.dll
libsndfile-1.dll => /mingw64/bin/libsndfile-1.dll (0x70440000)
2018-06-17 21:23:58 +08:00
```
Side-note: [fuslogvw](https://docs.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer) helps you debug .NET's run-time linker. Not relevant to juicysfplugin (because it's not managed code), but it's a useful tool for Windows developers to know about.
2018-06-17 21:23:58 +08:00
# 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
2018-06-14 05:00:06 +08:00
https://www.jetbrains.com/clion/nextversion/
2018-06-17 21:23:58 +08:00
## Install MinGW toolchain
2018-06-14 05:00:06 +08:00
Required for CLion integration.
https://stackoverflow.com/questions/36375081/how-to-run-clion-with-msys2-on-windows
You don't need all the packages here (like Ada, Fortran, Objective-C...), but space is cheap so just install all.
```bash
pacman -S --needed mingw-w64-x86_64-toolchain
```
2018-06-17 21:23:58 +08:00
## Configure CLion
2018-06-14 05:00:06 +08:00
Add MinGW Toolchain:
```
C:\msys64\mingw64
```
2018-06-17 21:23:58 +08:00
# Want to use Visual Studio upon a CMake project?
2018-06-17 21:23:58 +08:00
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.
2018-06-17 21:23:58 +08:00
## Configure Visual Studio build environment
2018-06-17 21:23:58 +08:00
https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC#Settingtheenvironment
2018-06-17 21:23:58 +08:00
Sets source and target architecture to x64:
2018-06-17 21:23:58 +08:00
```cmd
"C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
```
2018-06-17 21:23:58 +08:00
## Configure MSYS2 environment
2018-06-17 21:23:58 +08:00
Press the Start key to search for and launch an MSYS2 command prompt. Named `MSYS2 MinGW 64-bit`.
2018-06-17 21:23:58 +08:00
Ensure that on MSYS2's path, Visual Studio's cl and link programs have the highest precedence:
```bash
2018-06-17 21:23:58 +08:00
echo 'export PATH="/c/Program Files (x86)/Microsoft Visual Studio/Preview/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/:$PATH"' >> ~/.bashrc
```
2018-06-17 21:23:58 +08:00
Ensure that any libs or headers you wish to include are added to the path:
2018-06-17 21:23:58 +08:00
```bash
echo 'export LIB="EXAMPLE:$LIB"' >> ~/.bashrc
echo 'export INCLUDE="EXAMPLE:$INCLUDE"' >> ~/.bashrc
```
2018-06-14 06:42:45 +08:00
2018-06-17 21:23:58 +08:00
## Install LLVM
2018-06-14 06:42:45 +08:00
2018-06-17 21:23:58 +08:00
I can't remember why, since this seems to be switching to a different toolchain or compiler altogether.
Maybe it was an alternative approach.
2018-06-17 21:23:58 +08:00
https://releases.llvm.org/download.html
2018-06-17 21:23:58 +08:00
# Glossary
2018-06-17 21:23:58 +08:00
https://github.com/msys2/msys2/wiki/How-does-MSYS2-differ-from-Cygwin
```
2018-06-17 21:23:58 +08:00
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.
2018-06-17 21:23:58 +08:00
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.
2018-06-17 21:23:58 +08:00
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.
```