Birch-san / juicysfplugin

Audio plugin (e.g. VST, AU) to play soundfonts on macOS, Windows, Linux
GNU General Public License v3.0
209 stars 27 forks source link

Attempting to build on Linux #58

Open lapspider45 opened 9 months ago

lapspider45 commented 9 months ago

Hi! Been enjoying your plugin for a while now, though I always felt it was a shame there is no linux version. So I decided to try building it!

My goal is to get a VST3 build to work on Manjaro Linux / Arch.

Steps taken

  1. install dependencies: sudo pacman -S fluidsynth vst3sdk juce
  2. CMake setup: cmake -S . -B build inside the juicysfplugin dir
  3. trying to build: cmake --build build

At the last step it gives a compilation error. Looks like an easy fix, but my C++ knowledge is next to zero so I couldn't figure out how to fix it even after googling it.

[  2%] Building CXX object CMakeFiles/JuicySFPlugin.dir/Source/FluidSynthModel.cpp.o

... (omitted a bunch of warnings)

/home/axel/source/juicysfplugin/Source/FluidSynthModel.cpp:434:39: error: invalid conversion from ‘float* const*’ to ‘float**’ [-fpermissive]
  434 |         buffer.getArrayOfWritePointers());
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      |                                       |
      |                                       float* const*

... (omitted a bunch of warnings)

make[2]: *** [CMakeFiles/JuicySFPlugin.dir/build.make:90: CMakeFiles/JuicySFPlugin.dir/Source/FluidSynthModel.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:107: CMakeFiles/JuicySFPlugin.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Still, it looks promising so far! Any help would be appreciated.

lapspider45 commented 9 months ago

Update: getting past compilation now

Steps needed

  1. all the setup from above
  2. add add_compile_options(-fpermissive -w) to the top of CMakeLists.txt (-w is probably not necessary but it looks cleaner with)
  3. cmake --build build --target JuicySFPlugin_VST3 because the standalone version errors out when compiling

This time it gets this far before any errors:

...
[ 91%] Building CXX object CMakeFiles/JuicySFPlugin_VST3.dir/usr/share/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp.o
[ 94%] Building CXX object CMakeFiles/JuicySFPlugin_VST3.dir/usr/share/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp.o
[ 97%] Building CXX object CMakeFiles/JuicySFPlugin_VST3.dir/usr/share/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp.o
[100%] Linking CXX shared module JuicySFPlugin_artefacts/Release/VST3/juicysfplugin.vst3/Contents/x86_64-linux/juicysfplugin.so
/usr/bin/ld: cannot find -lpulsecommon-16.1: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/JuicySFPlugin_VST3.dir/build.make:232: JuicySFPlugin_artefacts/Release/VST3/juicysfplugin.vst3/Contents/x86_64-linux/juicysfplugin.so] Error 1
make[2]: *** [CMakeFiles/Makefile2:158: CMakeFiles/JuicySFPlugin_VST3.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:165: CMakeFiles/JuicySFPlugin_VST3.dir/rule] Error 2
make: *** [Makefile:196: JuicySFPlugin_VST3] Error 2

It looks like it's missing a dependency related to pulseaudio? That shouldn't be necessary for a VST3 build right? Hope there is a way to disable that.

lapspider45 commented 9 months ago

Only just noticed that there is a linux branch. Tried running the docker build, but sadly it also fails in the linker.

``` 11.90 [100%] Linking CXX executable juceaide_artefacts/Debug/juceaide 11.90 11.90 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libm-2.35.a(e_pow.o): warning: 11.90 relocation against `_dl_x86_cpu_features' in read-only section `.text' 11.90 11.90 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libm-2.35.a(s_atan.o): in function 11.90 `__atan_ifunc': 11.90 11.90 (.text+0x526): undefined reference to `_dl_x86_cpu_features' 11.90 11.90 /usr/bin/ld: (.text+0x531): undefined reference to `_dl_x86_cpu_features' 11.90 11.90 /usr/bin/ld: (.text+0x53a): undefined reference to `_dl_x86_cpu_features' 11.90 11.90 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libm-2.35.a(s_ceil.o): in function 11.90 `__ceil_ifunc': 11.90 11.90 (.text+0x6): undefined reference to `_dl_x86_cpu_features' 11.90 11.90 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libm-2.35.a(s_floor.o): in function 11.90 `__floor_ifunc': 11.90 11.90 (.text+0x6): undefined reference to `_dl_x86_cpu_features' 11.90 11.90 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libm-2.35.a(s_sin.o):(.text+0x12c6): 11.90 more undefined references to `_dl_x86_cpu_features' follow 11.90 11.90 /usr/bin/ld: warning: creating DT_TEXTREL in a PIE 11.90 11.90 clang: error: linker command failed with exit code 1 (use -v to see 11.90 invocation) 11.90 11.90 gmake[2]: *** 11.90 [extras/Build/juceaide/CMakeFiles/juceaide.dir/build.make:201: 11.90 extras/Build/juceaide/juceaide_artefacts/Debug/juceaide] Error 1 11.90 11.90 gmake[1]: *** [CMakeFiles/Makefile2:131: 11.90 extras/Build/juceaide/CMakeFiles/juceaide.dir/all] Error 2 11.90 11.90 gmake: *** [Makefile:136: all] Error 2 11.90 11.90 11.90 11.90 -- Configuring incomplete, errors occurred! 11.90 See also "/JUCE/build/CMakeFiles/CMakeOutput.log". 11.91 gmake: Makefile: No such file or directory 11.91 gmake: *** No rule to make target 'Makefile'. Stop. 11.91 cp: cannot create directory '/linux_native/lib/cmake/JUCE-*/': No such file or directory ------ Dockerfile:285 -------------------- 283 | RUN ./clone_juce.sh 284 | COPY llvm-scripts/juce/make_juce.sh make_juce.sh 285 | >>> RUN ./make_juce.sh 286 | 287 | # FROM toolchain-common AS msys2_deps -------------------- ERROR: failed to solve: process "/bin/sh -c ./make_juce.sh" did not complete successfully: exit code: 1 ``` Needless to say these errors go way above my head.
lapspider45 commented 9 months ago

Ugh... debugging cmake is so fatiguing...

At least I've figured out a few things, using the linux branch and docker build

  1. we can comment out everything in the dockerfile except blocks belonging to linux_*_x86_64, this is necessary for the below steps:
  2. the linker errors in make_juce.sh go away if we use the official branch instead: making sure the git command being run in clone_juce.sh is exec git clone --branch 6.1.6 --depth 1 https://github.com/juce-framework/JUCE.git. According to your comments, this won't build for windows platforms but in my case I don't care about that.
  3. in that case we also need to comment out the last line in make_juce.sh

After all this, it gets as far as building fluidsynth successfully. However, it either looks in the wrong directory for the fluidsynth binary or it's not built at all, possibly due to building with --target libfluidsynth in make_fluidsynth.sh. But I can't for the life of me figure out what effect --target libfluidsynth has on the build from simply looking at the cmake related files. Naturally, it does not build without specifying this target. Who designed this piece of trash build system?

Well, it's progress. Below is the latest part where I got stuck.

``` 2.367 [100%] Linking CXX static library libfluidsynth.a 2.409 [100%] Built target libfluidsynth 2.421 -- Install configuration: "Release" 2.421 -- Installing: /fluidsynth/prefix/lib64/pkgconfig/fluidsynth.pc 2.422 CMake Error at build_linux_/src/cmake_install.cmake:52 (file): 2.422 file INSTALL cannot find "/fluidsynth/build_linux_/src/fluidsynth": No such 2.422 file or directory. 2.422 Call Stack (most recent call first): 2.422 build_linux_/cmake_install.cmake:51 (include) 2.422 2.422 ------ Dockerfile:345 -------------------- 343 | RUN ./configure_fluidsynth.sh 344 | COPY llvm-scripts/fluidsynth/make_fluidsynth.sh make_fluidsynth.sh 345 | >>> RUN ./make_fluidsynth.sh 346 | 347 | #FROM linux_deps_i386 AS make_fluidsynth_linux_i386 -------------------- ERROR: failed to solve: process "/bin/sh -c ./make_fluidsynth.sh" did not complete successfully: exit code: 1 ```
napcode commented 7 months ago

Hi @lapspider45

seems like you tried building this on archlinux. I played around a bit and pushed a branch here. Not exactly beautiful but it does build the VST3.