We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5030

Summary: Compile for iOS without joystick fails
Product: SDL Reporter: Ron Aaron <ron>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: 2.0.10Keywords: target-2.0.14
Hardware: ARM   
OS: iOS (All)   

Description Ron Aaron 2020-03-15 06:03:01 UTC
If I compile normally, the linker complains about a lot of missing joystick stuff.  If I compile with --disable-joystick, I still get:

Undefined symbols for architecture armv7:
  "_HIDAPI_UpdateDevices", referenced from:
      _SDL_JoystickUpdate in libSDL2.a(SDL_joystick.o)
  "_SDL_AppleTVRemoteOpenedAsJoystick", referenced from:
      -[SDL_uikitview pressesBegan:withEvent:] in libSDL2.a(SDL_uikitview.o)
      -[SDL_uikitview pressesEnded:withEvent:] in libSDL2.a(SDL_uikitview.o)
      -[SDL_uikitview pressesCancelled:withEvent:] in libSDL2.a(SDL_uikitview.o)
  "_SDL_HIDAPI_JoystickDriver", referenced from:
      _SDL_joystick_drivers in libSDL2.a(SDL_joystick.o)
  "_SDL_IOS_JoystickDriver", referenced from:
      _SDL_joystick_drivers in libSDL2.a(SDL_joystick.o)
Comment 1 Sam Lantinga 2020-03-16 20:18:54 UTC
Is this using Xcode? If not, how are you building it?
Comment 2 Ron Aaron 2020-03-17 04:49:10 UTC
Using 'build-scripts/iosbuild.sh'
Comment 3 Ron Aaron 2020-03-17 04:51:34 UTC
Just FYI, I have a similar issue on Android in that the created libSDL2.a is missing things: 

./src/joystick/hidapi/SDL_hidapijoystick.c:573: error: undefined reference to 'hid_init'
./src/joystick/hidapi/SDL_hidapijoystick.c:811: error: undefined reference to 'hid_enumerate'


that's created using the androidbuildlibs.sh script on Linux. Should I open a separate bug for that?
Comment 4 Sam Lantinga 2020-05-27 17:41:55 UTC
Can you try the latest SDL snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip

You shouldn't get iOS errors about missing joystick stuff anymore when you build normally.
If you build on iOS without joystick support you'll need to edit include/SDL_config_iphoneos.h to define SDL_JOYSTICK_DISABLED and comment out the other JOYSTICK drivers listed there.

On Android I recommend using the shared library. If you don't, you'll need to link with hidapi, which is only available as a shared library:
[armeabi-v7a] SharedLibrary  : libhidapi.so
[armeabi-v7a] Compile thumb  : cpufeatures <= cpu-features.c
[armeabi-v7a] StaticLibrary  : libcpufeatures.a
[armeabi-v7a] SharedLibrary  : libSDL2.so
[armeabi-v7a] Install        : libSDL2.so => build/android/lib/armeabi-v7a/libSDL2.so
[armeabi-v7a] StaticLibrary  : libSDL2main.a
[armeabi-v7a] Install        : libhidapi.so => build/android/lib/armeabi-v7a/libhidapi.so

Does this take care of the issues you're running into?
Comment 5 Ryan C. Gordon 2020-06-27 01:55:16 UTC
This bug appears to be resolved. Ron, if you're still having issues, please reopen it and we'll look into it further. Thanks!

--ryan.