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 4419

Summary: Undefined symbols for SDL_COREMOTION_SensorDriver on iOS using CMake
Product: SDL Reporter: Steve Robinson <ssrobins>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.9   
Hardware: iPhone/iPod touch   
OS: macOS 10.13   

Description Steve Robinson 2018-12-10 00:37:15 UTC
When building SDL2 2.0.9 on iOS with a CMake-generated Xcode project, I get this linker error:

Undefined symbols for architecture armv7:
  "_SDL_COREMOTION_SensorDriver", referenced from:
      _SDL_SensorInit in libSDL2.a(SDL_sensor.o)
      _SDL_SensorQuit in libSDL2.a(SDL_sensor.o)
      _SDL_SensorUpdate in libSDL2.a(SDL_sensor.o)
ld: symbol(s) not found for architecture armv7

Full build output:
https://gitlab.com/ssrobins/sdl2-example/-/jobs/132014142

To fix it, I replaced the following in the CMakeLists.txt file:
if(SDL_SENSOR)
  file(GLOB SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/*.c)
  set(SOURCE_FILES ${SOURCE_FILES} ${SENSOR_SOURCES})
endif()

With this:
if(SDL_SENSOR)
  file(GLOB SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/*.c)
  if(IOS)
    file(GLOB EXTRA_SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/coremotion/*.m)
  endif()
  set(SOURCE_FILES ${SOURCE_FILES} ${SENSOR_SOURCES} ${EXTRA_SENSOR_SOURCES})
endif()

Commit:
https://gitlab.com/ssrobins/conan-sdl2/commit/020262ad603471a32aac24b8d48202003d55691e
I also employed the build changes described here https://bugzilla.libsdl.org/show_bug.cgi?id=4178, which you can see in the referenced commit above.
Comment 1 Steve Robinson 2020-04-06 04:46:50 UTC
It's fixed in SDL 2.0.12. Thanks!