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 4194

Summary: Fix linker error when using CMake/Xcode to build an iOS app for arm64
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.12   
Hardware: iPhone/iPod touch   
OS: macOS 10.13   
Attachments: Modified SDL2 CMakeLists.txt file

Description Steve Robinson 2018-06-09 00:20:51 UTC
Created attachment 3259 [details]
Modified SDL2 CMakeLists.txt file

When I use CMake to generate an Xcode project and then try to link SDL2 to a program that uses it for iOS arm64, I get this error:
Undefined symbols for architecture arm64:
  "_METAL_RenderDriver", referenced from:
      _render_drivers in libSDL2d.a(SDL_render.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I perform the CMake project generation and build steps with the following commands:
mkdir _build
cd _build
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DENABLE_BITCODE=FALSE ..
cmake --build . --config Release

I'm using the compiler that comes with Xcode 9.4 to build.

The toolchain file, ios.toolchain.cmake, is from here:
https://github.com/leetal/ios-cmake


It's missing a source file in SDL2 to define this symbol.  I fix it by adding the following after file(GLOB SOURCE_FILES in CMakeLists.txt:
if(IOS)
   set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/render/metal/SDL_render_metal.m)
endif()


I also need to add "-framework Metal" to the IOS_FRAMEWORKS list originally added in this bug report:
https://bugzilla.libsdl.org/show_bug.cgi?id=4178

The CMakeLists.txt file with these changes and the changes from my other build bugs is attached.

Verified that iOS builds for armv7, armv7s, arm64, and the x86_64 simulator still work along with Windows, Linux, Mac, and Android.
Comment 1 Steve Robinson 2020-04-19 05:34:42 UTC
This is still an issue in SDL 2.0.12.
Comment 2 Steve Robinson 2020-12-25 07:36:10 UTC
Fixed in SDL 2.0.14, thanks!