Skip to content

Build fails on Windows when unicode is enabled due to incompatible entry point name with SDL2 #1472

@kalibera

Description

@kalibera

Building fluidsynth (version 2.4.2) for Windows fails when trying to link fluidsynth.exe, SDL_main is not found (SDL2 version 2.30.11), when unicode support (UNICODE) is enabled, which is the default. I am not sure whether it is a bug of fluidsynth or sdl2, but the technical cause is as follows.

SDL_main is supposed to be the entry point in the application, so in fluidsynth.exe, but it is not. The problem is that SDL2 expects that the application would define its entry point as "main" even when building with unicode enabled (and SDL2 renames it to "SDL_main"). See the SDL.h file:

/**
 *  \file SDL_main.h
 *
 *  The application's main() function must be called with C linkage,
 *  and should be declared like this:
 *  \code
 *  #ifdef __cplusplus
 *  extern "C"
 *  #endif
 *  int main(int argc, char *argv[])
 *  {
 *  }
 *  \endcode
 */

However, fluidsynth defines the entry point as "wmain", so it won't be renamed to SDL_main, and the symbol wouldn't be found. It is indeed not just the name of the entry point, but also the arguments - SDL2 expects that the entry point would accept narrow characters. One can build fluidsynth fine when "unicode" is disabled per cmake option "-Denable-unicode=OFF".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions