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 - Fix linker error when using CMake/Xcode to build an iOS app for arm64
Summary: Fix linker error when using CMake/Xcode to build an iOS app for arm64
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.12
Hardware: iPhone/iPod touch macOS 10.13
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-09 00:20 UTC by Steve Robinson
Modified: 2020-12-25 07:36 UTC (History)
0 users

See Also:


Attachments
Modified SDL2 CMakeLists.txt file (63.26 KB, text/plain)
2018-06-09 00:20 UTC, Steve Robinson
Details

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