| Summary: | Undefined symbols for SDL_COREMOTION_SensorDriver on iOS using CMake | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Steve Robinson <ssrobins> |
| Component: | build | Assignee: | 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 | ||
It's fixed in SDL 2.0.12. Thanks! |
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.