swesterfeld / liquidsfz

SFZ Sampler
Mozilla Public License 2.0
86 stars 12 forks source link

liquidsfz on windows #21

Open midimusic opened 3 years ago

midimusic commented 3 years ago

I am a new potential user of liquidsfz and have tried to compile it on Windows. I used CMake for windows and it immediately threw up an error that there was no CMakeLists.txt file. I solved this by using the CMakeLists.txt file which came with fluidsynth (which I successfully compiled - several years ago - for use as a .dll on Windows).

The initial configure worked but threw up a lot of red errors that prevented any further progress.

As I am not a CMake or Linux expert please can you provide a suitable CMakeLists.txt file. I will test it out and report progress as I am a proficient user of c++ and Windows.

The alternative would be for me to make my own Makefile which I could do as I use mingw on windows.

At present my organ eplayOrgan uses fluidsynth and works exceptionally well but I am hoping for a liquidsfz .dll which works equally well for sfz sound fonts.

You can see eplayOrgan on my website https://midimusic.github.io eplayOrgan is completely free to download and use. My email address is in About. It will work on Linux under Wine if you want to try it out.

csw900

swesterfeld commented 3 years ago

Ok, I'm not a CMake expert either (never used it in any project), but I have added testCMakeLists.txt to the repository https://github.com/swesterfeld/liquidsfz/commit/d59519bb7eb0be6bf2aeca6c56aaf92e269f3855 - you need to rename it to CMakeLists.txt. I tested it on linux, it builds here, I don't know if anything needs to be done to make it build on windows.

midimusic commented 3 years ago

Thanks, I have tried it and it still gives errors. I understand that the PkgConfig error can be ignored as Windows does not need it. I have turned off all the options except the basic minimum. I do not claim to fully understand any of the results but suspect some file is needed which is not on my PC.

Console output attached console_output.txt

I have also attached the CmakeOutput.log which looks OK as far as it goes. CMakeOutput.log These files were dragged and dropped and I hope successfully. csw900

swesterfeld commented 3 years ago

For a successful build of liquidsfz, you need libsndfile. I used pkg-config to find it, as this is how its typically done on Linux. But there is a second way to find libsndfile, via CMake using find_package. This only works if libsndfile's SndFileConfig.cmake is available (but should be if you use sndfile 1.0.30 or newer). So I hope this will work for you: https://github.com/swesterfeld/liquidsfz/commit/ce8086eefc186aef5a6831aa1a31473c65c38488

midimusic commented 3 years ago

Thanks. I do have libsndfile-1.0.28 on my system and have had a look at it - it is in mingw32\deps\bin\libsndfile-1.0.28 and has to be compiled from source using cmake. It is well hidden and that is probably why cmake does not find it. I may be able to update it to a later version or move it to somewhere easier to find (such as in your source code??) There is no SndFileConfig.cmake file.

I will do a few experiments and let you know the results later. csw900

midimusic commented 3 years ago

I now have libsndfile as both 32 and 64 bit binaries available on my system (I downloaded them from their website). I do have the latest version of mingw32 and understand that it can make both 32 and 64 bit binaries depending on the makefile contents. I need to make a 64 bit dll for liquid.sfz so that I can use its api in my program.

I commented out the relevant part of your CMakeLists.txt file and configure now completes without error. However I suspect this file is short of "something???" as nothing gets compiled when I use cmake to generate code. I have noted that your file seems rather short compared to others.

What is the next step? csw900

midimusic commented 3 years ago

I have now done a bit if research on CMakeLists and had a good look at the fluidsynth version (attached). I have successfully compiled fluidsynth (several years ago) on my Windows system and it produced a satisfactory .dll with all the characteristics needed for real time midi input on a windows program. This is the version used in eplayOrgan.

fluidsynthCMakeLists.txt

I think you could do a lot worse than base your CMakeLists file on this. Good luck csw900

swesterfeld commented 3 years ago

I have now tried myself to build under windows in an mingw environment I got from www.msys2.org. It turns out that the first version of CMakeLists.txt that I suggested works flawlessly in mingw/msys. So using pkg-config should make the compiler use the libsndfile bundled with mingw. Note that the second version of CMakeLists.txt did not work because the libsndfile bundled with mingw is 1.0.28 (which is what you reported as well). This version does not have SndFileConfig.cmake as therefore cannot be found with find_package.

I am attaching a log of a successful build. The only portability issue I ran into (and fixed) is that vasprintf() is not available on windows ( https://github.com/swesterfeld/liquidsfz/commit/4f913491f3bfbd0d590d4b90933e1da07f7f1c8a )

liquidsfz.log

As for the CMakeLists.txt being shorter than for other projects, yes that is true. One factor is that this CMakeLists.txt only builds the dll, nothing more (no jack client, lv2 plugin, tests). This can be added over time. But as you have only asked for a .dll, this should only produce what you need.

Not sure what is wrong here. I see in your first log two things. First, you use gcc 6.3.0, that is really old (you'll see my log reports 9.2.0). So this could become a problem later on but shouldn't prevent cmake running at the first place. But your log also doesn't have pkg-config. It might be possible to install pkg-config for you using the package manager (at least my mingw environment - installed from https://www.msys2.org/ has a package manager and I can install pkg-config using pacman -S pkg-config).

swesterfeld commented 3 years ago

I had yet another idea for a new attempt to make CMakeLists.txt build without pkg-config. I'll try once I have the time to do it and let you know.

midimusic commented 3 years ago

My installation of mingw probably does not have all the bells and whistles that msys2 has so I have now installed msys2 as you indicated and will try again with your original CMakeLists.txt file - however this is a new package to me and will take a bit of getting used to. Will let you know how I get on but it may take a while. csw900

midimusic commented 3 years ago

Please tell me EXACTLY where cmake (Windows cmake-gui) expects to find libsndfile and EXACTLY what it expects to find (you say "pkg_search_module (LIBSNDFILE REQUIRED sndfile>=1.0.0)".

I have used cmake to compile libsndfile (downloaded from their website) and have put the resulting "libsndfile-1.0.30" folder (including the "build" folder) into every place in mysys2 that I think is sensible and it is never found by cmake.

I have also tried changing your search line to "pkg_search_module (LIBSNDFILE REQUIRED libsndfile>=1.0.0)" and this is not found either.

The cmake help is not helpful and neither is the mysys2 man.

Thank you csw900

swesterfeld commented 3 years ago

pkg-config looks for a .pc file, which on my installation is in /c/msys64/mingw64/lib/pkgconfig/sndfile.pc and it looks like this:

$ cat /c/msys64/mingw64/lib/pkgconfig/sndfile.pc
prefix=/mingw64
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sndfile
Description: A library for reading and writing audio files
Requires:
Version: 1.0.28
Libs: -L${libdir} -lsndfile
Libs.private: -L/mingw64/lib -lFLAC -L/mingw64/lib -logg -L/mingw64/lib -lvorbis -L/mingw64/lib -lvorbisenc -L/mingw64/lib -lspeex
Cflags: -I${includedir}

To get it, you can install libsndfile into msys2 using pacman

$ pacman -S mingw-w64-x86_64-libsndfile

You should also probably install cmake, pkgconfig and everything else you need to build into msys2. At least for the build log I posted above, I used cmake from within a msys2 shell, make within msys2 shell, and pkgconfig and cmake from msys2. The exact cmake command line for building within msys2 (note the -G) I used was

$ cmake .. -G 'MSYS Makefiles'

You can test pkgconfig in msys2 manually without cmake by running

$ pkg-config --modversion sndfile
1.0.28
midimusic commented 3 years ago

Thank you for the very useful information.

Using the msys64 command line: I now have libsndfile installed into msys64 using pacman as you suggested. I have also successfully installed cmake and checked that make is already installed. I have successfully run your cmake command above with no errors and it has produced a Makefile in the build folder. However I have not been able to use this makefile to actually compile anything. As soon as I change directory to the build folder make calls up a windows 10 make executable rather than the correct msys64 make. Anyway neither of the executable makes does anything other than sign on and immediately exit. My command is "make -f Makefile". Note that the msys64 make.exe is located in msys64\usr\bin and I have made sure this is on the PATH. What am I doing wrong? Can I use cmake to compile using the Makefile it has made? As I said above I am not a cmake expert so please excuse my lack of knowledge in this area. csw900

midimusic commented 3 years ago

Herewith attached are the two makefiles produced. As far as I can tell NOTHING gets compiled when they are invoked.

Looking through them I can see no reference to a compiler!!

It would save me a lot of time and annoyance if you would send me a copy of your windows liquidsfz dll or put it on line. At this moment I have given up on your liquidsfz and will be trying other solutions. However I have to convert eplayOrgan to 64 bits before anything much comes of these experiments.

At present there are no organ sound fonts in sfz format - so this is another problem to be solved.

csw900

Makefile.zip Makefile2.zip

swesterfeld commented 3 years ago

Ok, the original plan of me writing a perfect CMakeLists.txt without testing it and without knowing in which environment it would be used and you testing it without knowing anything about how the CMakeLists.txt works failed. So I had to take the time to actually test building on Windows myself and write a few instructions on how to build.

My first attempt was trying to produce instructions for MSYS, something like "download - upgrade - install packages X Y Z - run cmake - run make". However the build that succeeded in my old MSYS environment didn't work in a fresh MSYS environment; so the success I had before with MSYS didn't reproduce on a new MSYS environment, probably because lots of packages were updated. So this is bad, because if I write instructions on how to build using MSYS, a newer MSYS update may break the instructions again.

So my second attempt was to take gcc/g++ from mingw-w64 and build using these compilers. This was successful, interestingly with the second version of CMakeLists.txt I committed before. I documented the steps here: https://github.com/swesterfeld/liquidsfz/blob/master/README_WINDOWS.md

Note that it compiles doesn't necessarily mean that it works, too, so please provide feedback if something doesn't work.

At the moment providing pre-compiled .dlls is not very high on my priority list. It could become more relevant in the future if all of the build could be done with CMake, because then the .dll for the LV2 plugin (or if we ever add a VST plugin) would be used by end users, which would make it more useful to provide binary .dlls. In that scenario it might be the best option for me to cross-compile the binaries, so I wouldn't have to use a windows system at all.