renpy / pygame_sdl2

Reimplementation of portions of the pygame API using SDL2.
GNU Lesser General Public License v2.1
325 stars 63 forks source link

error LNK2001: unresolved external symbol SDL_JoystickGetDeviceInstanceID #153

Closed heeeeeeeeeeh closed 1 month ago

heeeeeeeeeeh commented 4 months ago

On the sdl2 branch in libsdl-org/SDL there is a function SDL_JoystickGetDeviceInstanceID in joystick.h. I don't see it in the version of sdl2 the pygame_sdl_windeps repo has which is why the build fails. Is a newer version of SDL needed for the build to work?

yg195329 commented 1 month ago

I just ran into the same issue. I am not the maintainer, but I looked into it and managed to get pygame_sdl2 to compile successfully. Your analysis is correct, but SDL_JoystickGetDeviceInstanceID is only the beginning of the problems. The various commits made to this repo require other symbols that are also missing from renpy/pygame_sdl2_windeps.

Here is what I did on Windows in case it is useful to anyone:

  1. Git clone renpy/pygame_sdl2 and add renpy/pygame_sdl2_windeps as a submodule.
  2. Download SDL2-devel-2.0.14-VC from https://www.libsdl.org/release/ and move it inside the pygame_sdl2/pygame_sdl2_windeps directlry.
  3. Run "python ./unpack.py SDL2-devel-2.0.14-VC.zip" from the pygame_sdl2/pygame_sdl2_windeps directory. This will overwrite all the relevant files in the include/ and lib/ subdirectories
  4. (optional) Depending on your compiler, you may run into an unrelated error with src/SDL_gfxPrimitives.c. Recent versions of MSVC define lrint() as an intrinsic function whereas the #ifdef pragma assumes this function to be missing for that compiler. Ideally, the pragma should be updated to check the version number. If all you care is creating a new binary and not committing any changes, I suggest simply removing the entire #ifdef block.
  5. Rerun "python setup.py install" in the pygame_sdl2 directory.