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 - Undefined symbols for SDL_COREMOTION_SensorDriver on iOS using CMake
Summary: Undefined symbols for SDL_COREMOTION_SensorDriver on iOS using CMake
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.9
Hardware: iPhone/iPod touch macOS 10.13
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-10 00:37 UTC by Steve Robinson
Modified: 2020-04-06 04:46 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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!