The problem comes because qsynth and Qt are linked to the DLL C runtime (dynamic runtime, flag /MD) but fluidsynth is linked with the static C runtime library, flag /MT).
The solution is to compile everything using dynamic or static C runtime library, but not mixing both. The easiest fix is to modify fluidsynth CMake buildsystem to make use of the DLL C runtime, because rebuilding each Qt version with the static C runtime is very time consuming.
This is the relevant part of fluidsynth's CMakeList.txt
if ( MSVC )
# statically link in the CRT library to avoid a bunch of runtime DLL dependencies and allow
# the CI windows builds to be run under WinXP
# foreach ( flag_var
# CMAKE_C_FLAGS
# CMAKE_C_FLAGS_DEBUG
# CMAKE_C_FLAGS_RELEASE
# CMAKE_C_FLAGS_MINSIZEREL
# CMAKE_C_FLAGS_RELWITHDEBINFO
# CMAKE_CXX_FLAGS
# CMAKE_CXX_FLAGS_DEBUG
# CMAKE_CXX_FLAGS_RELEASE
# CMAKE_CXX_FLAGS_MINSIZEREL
# CMAKE_CXX_FLAGS_RELWITHDEBINFO
# )
# if ( ${flag_var} MATCHES "/MD" )
# string ( REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}" )
# endif ( ${flag_var} MATCHES "/MD" )
# endforeach ( flag_var )
I will request to add a new configurable option to fluidsynth. Meanwhile, lets keep this ticket as a remainder.
When testing qsynth compiled with the MSVC++ compiler, pressing the "setup..." button throws this message box and dies:
It is the same problem documented here: https://docs.microsoft.com/en-us/answers/questions/240332/assert-when-using-mtd-dynamic-library.html
The problem comes because qsynth and Qt are linked to the DLL C runtime (dynamic runtime, flag /MD) but fluidsynth is linked with the static C runtime library, flag /MT).
The solution is to compile everything using dynamic or static C runtime library, but not mixing both. The easiest fix is to modify fluidsynth CMake buildsystem to make use of the DLL C runtime, because rebuilding each Qt version with the static C runtime is very time consuming.
This is the relevant part of fluidsynth's CMakeList.txt
I will request to add a new configurable option to fluidsynth. Meanwhile, lets keep this ticket as a remainder.