[Solved] SDL3: Build errors when trying to compile sample Android App

For SDL3, trying the example of building the test App “./create-android-project.py org.libsdl.testgles …/test/testgles.c” as described in the README-android.md. I’m running Arch Linux and have installed Android Studio and jdk21-openjdk. I get the same errors when trying to build it in Android Studio. Spent some time trying to debug the issue but didn’t see anything out of order.

Below you can see the steps taken to build the test Android app, setting up a fresh build environment. For some reason, it’s skipping the building of the SDL/src/test folder.

[howie@howieputer ~]$ export ANDROID_NDK_HOME=/home/howie/Android/Sdk/ndk
[howie@howieputer ~]$ export ANDROID_HOME=/home/howie/Android/Sdk
[howie@howieputer ~]$ export JAVA_HOME=/usr/lib/jvm/default
[howie@howieputer ~]$ cd Development/SDL/build-scripts/
[howie@howieputer build-scripts]$ ./create-android-project.py org.libsdl.testgles ../test/testgles.c
To build and install to a device for testing, run the following:
cd /home/howie/Development/SDL/build/org.libsdl.testgles
./gradlew installDebug
[howie@howieputer build-scripts]$ cd ../build/org.libsdl.testgles/
[howie@howieputer org.libsdl.testgles]$ ./gradlew installDebug

Task :app:buildNdkBuildDebug[arm64-v8a] FAILED
C/C++: ld.lld: error: undefined symbol: SDLTest_CommonCreateState
C/C++: >>> referenced by testgles.c:113 (app/jni/src/testgles.c:113)
C/C++: >>> /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)
C/C++: ld.lld: error: undefined symbol: SDLTest_CommonArg
C/C++: >>> referenced by testgles.c:121 (app/jni/src/testgles.c:121)
C/C++: >>> /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)
C/C++: ld.lld: error: undefined symbol: SDLTest_CommonLogUsage
C/C++: >>> referenced by testgles.c:148 (app/jni/src/testgles.c:148)
C/C++: >>> /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)
C/C++: ld.lld: error: undefined symbol: SDLTest_CommonInit
C/C++: >>> referenced by testgles.c:170 (app/jni/src/testgles.c:170)
C/C++: >>> /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)
C/C++: ld.lld: error: undefined symbol: SDLTest_CommonEvent
C/C++: >>> referenced by testgles.c:297 (app/jni/src/testgles.c:297)
C/C++: >>> /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)
C/C++: ld.lld: error: undefined symbol: SDLTest_CommonQuit
C/C++: >>> referenced by testgles.c:45 (app/jni/src/testgles.c:45)
C/C++: >>> /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(quit)
C/C++: clang: error: linker command failed with exit code 1 (use -v to see invocation)
C/C++: make: *** [/home/howie/Android/Sdk/ndk/27.0.12077973/build/core/build-binary.mk:661: /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/libmain.so] Error 1

[Incubating] Problems report is available at: file:///home/howie/Development/SDL/build/org.libsdl.testgles/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:buildNdkBuildDebug[arm64-v8a]’.

com.android.ide.common.process.ProcessException: Android NDK: android-19 is unsupported. Using minimum supported version android-21.
[arm64-v8a] Compile : SDL3 <= SDL.c
[arm64-v8a] Compile : SDL3 <= SDL_assert.c
[arm64-v8a] Compile : SDL3 <= SDL_error.c
[arm64-v8a] Compile : SDL3 <= SDL_guid.c
[arm64-v8a] Compile : SDL3 <= SDL_hashtable.c
[arm64-v8a] Compile : SDL3 <= SDL_hints.c
[arm64-v8a] Compile : SDL3 <= SDL_list.c
[arm64-v8a] Compile : SDL3 <= SDL_log.c
[arm64-v8a] Compile : SDL3 <= SDL_properties.c
[arm64-v8a] Compile : SDL3 <= SDL_utils.c
[arm64-v8a] Compile : SDL3 <= SDL_audio.c
[arm64-v8a] Compile : SDL3 <= SDL_audiocvt.c
[arm64-v8a] Compile : SDL3 <= SDL_audiodev.c
[arm64-v8a] Compile : SDL3 <= SDL_audioqueue.c
[arm64-v8a] Compile : SDL3 <= SDL_audioresample.c
[arm64-v8a] Compile : SDL3 <= SDL_audiotypecvt.c
[arm64-v8a] Compile : SDL3 <= SDL_mixer.c
[arm64-v8a] Compile : SDL3 <= SDL_wave.c
[arm64-v8a] Compile : SDL3 <= SDL_dummyaudio.c
[arm64-v8a] Compile : SDL3 <= SDL_aaudio.c
[arm64-v8a] Compile : SDL3 <= SDL_openslES.c
[arm64-v8a] Compile : SDL3 <= SDL_atomic.c
[arm64-v8a] Compile : SDL3 <= SDL_spinlock.c
[arm64-v8a] Compile : SDL3 <= SDL_camera.c
[arm64-v8a] Compile : SDL3 <= SDL_camera_android.c
[arm64-v8a] Compile : SDL3 <= SDL_camera_dummy.c
[arm64-v8a] Compile : SDL3 <= SDL_core_unsupported.c
[arm64-v8a] Compile : SDL3 <= SDL_android.c
[arm64-v8a] Compile : SDL3 <= SDL_cpuinfo.c
[arm64-v8a] Compile : SDL3 <= SDL_dialog.c
[arm64-v8a] Compile : SDL3 <= SDL_dialog_utils.c
[arm64-v8a] Compile : SDL3 <= SDL_androiddialog.c
[arm64-v8a] Compile : SDL3 <= SDL_dynapi.c
[arm64-v8a] Compile : SDL3 <= SDL_categories.c
[arm64-v8a] Compile : SDL3 <= SDL_clipboardevents.c
[arm64-v8a] Compile : SDL3 <= SDL_displayevents.c
[arm64-v8a] Compile : SDL3 <= SDL_dropevents.c
[arm64-v8a] Compile : SDL3 <= SDL_events.c
[arm64-v8a] Compile : SDL3 <= SDL_eventwatch.c
[arm64-v8a] Compile : SDL3 <= SDL_keyboard.c
[arm64-v8a] Compile : SDL3 <= SDL_keymap.c
[arm64-v8a] Compile : SDL3 <= SDL_keysym_to_keycode.c
[arm64-v8a] Compile : SDL3 <= SDL_keysym_to_scancode.c
[arm64-v8a] Compile : SDL3 <= SDL_mouse.c
[arm64-v8a] Compile : SDL3 <= SDL_pen.c
[arm64-v8a] Compile : SDL3 <= SDL_quit.c
[arm64-v8a] Compile : SDL3 <= SDL_scancode_tables.c
[arm64-v8a] Compile : SDL3 <= SDL_touch.c
[arm64-v8a] Compile : SDL3 <= SDL_windowevents.c
[arm64-v8a] Compile : SDL3 <= imKStoUCS.c
[arm64-v8a] Compile : SDL3 <= SDL_asyncio.c
[arm64-v8a] Compile : SDL3 <= SDL_iostream.c
[arm64-v8a] Compile : SDL3 <= SDL_asyncio_generic.c
[arm64-v8a] Compile : SDL3 <= SDL_gpu.c
[arm64-v8a] Compile : SDL3 <= SDL_gpu_vulkan.c
[arm64-v8a] Compile : SDL3 <= SDL_haptic.c
[arm64-v8a] Compile : SDL3 <= SDL_syshaptic.c
[arm64-v8a] Compile : SDL3 <= SDL_syshaptic.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi.c
[arm64-v8a] Compile++ : SDL3 <= hid.cpp
[arm64-v8a] Compile : SDL3 <= SDL_gamepad.c
[arm64-v8a] Compile : SDL3 <= SDL_joystick.c
[arm64-v8a] Compile : SDL3 <= SDL_steam_virtual_gamepad.c
[arm64-v8a] Compile : SDL3 <= controller_type.c
[arm64-v8a] Compile : SDL3 <= SDL_sysjoystick.c
[arm64-v8a] Compile : SDL3 <= SDL_sysjoystick.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_combined.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_gamecube.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_luna.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_ps3.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_ps4.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_ps5.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_rumble.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_shield.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_stadia.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_steam.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_steam_hori.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_steamdeck.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_switch.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_wii.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_xbox360.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_xbox360w.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapi_xboxone.c
[arm64-v8a] Compile : SDL3 <= SDL_hidapijoystick.c
[arm64-v8a] Compile : SDL3 <= SDL_virtualjoystick.c
[arm64-v8a] Compile : SDL3 <= SDL_sysloadso.c
[arm64-v8a] Compile : SDL3 <= SDL_locale.c
[arm64-v8a] Compile : SDL3 <= SDL_syslocale.c
[arm64-v8a] Compile : SDL3 <= SDL_main_callbacks.c
[arm64-v8a] Compile : SDL3 <= SDL_runapp.c
[arm64-v8a] Compile : SDL3 <= SDL_sysmain_callbacks.c
[arm64-v8a] Compile : SDL3 <= SDL_url.c
[arm64-v8a] Compile : SDL3 <= SDL_sysurl.c
[arm64-v8a] Compile : SDL3 <= SDL_power.c
[arm64-v8a] Compile : SDL3 <= SDL_syspower.c
[arm64-v8a] Compile : SDL3 <= SDL_process.c
[arm64-v8a] Compile : SDL3 <= SDL_dummyprocess.c
[arm64-v8a] Compile : SDL3 <= SDL_filesystem.c
[arm64-v8a] Compile : SDL3 <= SDL_sysfilesystem.c
[arm64-v8a] Compile : SDL3 <= SDL_sysfsops.c
[arm64-v8a] Compile : SDL3 <= SDL_sensor.c
[arm64-v8a] Compile : SDL3 <= SDL_androidsensor.c
[arm64-v8a] Compile : SDL3 <= SDL_dummysensor.c
[arm64-v8a] Compile : SDL3 <= SDL_d3dmath.c
[arm64-v8a] Compile : SDL3 <= SDL_render.c
[arm64-v8a] Compile : SDL3 <= SDL_render_unsupported.c
[arm64-v8a] Compile : SDL3 <= SDL_yuv_sw.c
[arm64-v8a] Compile : SDL3 <= SDL_render_d3d.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_d3d.c
[arm64-v8a] Compile : SDL3 <= SDL_render_d3d11.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_d3d11.c
[arm64-v8a] Compile : SDL3 <= SDL_render_d3d12.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_d3d12.c
[arm64-v8a] Compile : SDL3 <= SDL_pipeline_gpu.c
[arm64-v8a] Compile : SDL3 <= SDL_render_gpu.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_gpu.c
[arm64-v8a] Compile : SDL3 <= SDL_render_gl.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_gl.c
[arm64-v8a] Compile : SDL3 <= SDL_render_gles2.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_gles2.c
[arm64-v8a] Compile : SDL3 <= SDL_render_ps2.c
[arm64-v8a] Compile : SDL3 <= SDL_render_psp.c
[arm64-v8a] Compile : SDL3 <= SDL_blendfillrect.c
[arm64-v8a] Compile : SDL3 <= SDL_blendline.c
[arm64-v8a] Compile : SDL3 <= SDL_blendpoint.c
[arm64-v8a] Compile : SDL3 <= SDL_drawline.c
[arm64-v8a] Compile : SDL3 <= SDL_drawpoint.c
[arm64-v8a] Compile : SDL3 <= SDL_render_sw.c
[arm64-v8a] Compile : SDL3 <= SDL_rotate.c
[arm64-v8a] Compile : SDL3 <= SDL_triangle.c
[arm64-v8a] Compile : SDL3 <= SDL_render_vita_gxm.c
[arm64-v8a] Compile : SDL3 <= SDL_render_vita_gxm_memory.c
[arm64-v8a] Compile : SDL3 <= SDL_render_vita_gxm_tools.c
[arm64-v8a] Compile : SDL3 <= SDL_render_vulkan.c
[arm64-v8a] Compile : SDL3 <= SDL_shaders_vulkan.c
[arm64-v8a] Compile : SDL3 <= SDL_crc16.c
[arm64-v8a] Compile : SDL3 <= SDL_crc32.c
[arm64-v8a] Compile : SDL3 <= SDL_getenv.c
[arm64-v8a] Compile : SDL3 <= SDL_iconv.c
[arm64-v8a] Compile : SDL3 <= SDL_malloc.c
[arm64-v8a] Compile : SDL3 <= SDL_memcpy.c
[arm64-v8a] Compile : SDL3 <= SDL_memmove.c
[arm64-v8a] Compile : SDL3 <= SDL_memset.c
[arm64-v8a] Compile : SDL3 <= SDL_mslibc.c
[arm64-v8a] Compile : SDL3 <= SDL_murmur3.c
[arm64-v8a] Compile : SDL3 <= SDL_qsort.c
[arm64-v8a] Compile : SDL3 <= SDL_random.c
[arm64-v8a] Compile : SDL3 <= SDL_stdlib.c
[arm64-v8a] Compile : SDL3 <= SDL_string.c
[arm64-v8a] Compile : SDL3 <= SDL_strtokr.c
[arm64-v8a] Compile : SDL3 <= SDL_storage.c
[arm64-v8a] Compile : SDL3 <= SDL_genericstorage.c
[arm64-v8a] Compile : SDL3 <= SDL_thread.c
[arm64-v8a] Compile : SDL3 <= SDL_syscond.c
[arm64-v8a] Compile : SDL3 <= SDL_sysmutex.c
[arm64-v8a] Compile : SDL3 <= SDL_sysrwlock.c
[arm64-v8a] Compile : SDL3 <= SDL_syssem.c
[arm64-v8a] Compile : SDL3 <= SDL_systhread.c
[arm64-v8a] Compile : SDL3 <= SDL_systls.c
[arm64-v8a] Compile : SDL3 <= SDL_time.c
[arm64-v8a] Compile : SDL3 <= SDL_systime.c
[arm64-v8a] Compile : SDL3 <= SDL_timer.c
[arm64-v8a] Compile : SDL3 <= SDL_systimer.c
[arm64-v8a] Compile : SDL3 <= SDL_tray.c
[arm64-v8a] Compile : SDL3 <= SDL_tray_utils.c
[arm64-v8a] Compile : SDL3 <= SDL_RLEaccel.c
[arm64-v8a] Compile : SDL3 <= SDL_blit.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_0.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_1.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_A.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_N.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_auto.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_copy.c
[arm64-v8a] Compile : SDL3 <= SDL_blit_slow.c
[arm64-v8a] Compile : SDL3 <= SDL_bmp.c
[arm64-v8a] Compile : SDL3 <= SDL_clipboard.c
[arm64-v8a] Compile : SDL3 <= SDL_egl.c
[arm64-v8a] Compile : SDL3 <= SDL_fillrect.c
[arm64-v8a] Compile : SDL3 <= SDL_pixels.c
[arm64-v8a] Compile : SDL3 <= SDL_rect.c
[arm64-v8a] Compile : SDL3 <= SDL_stb.c
[arm64-v8a] Compile : SDL3 <= SDL_stretch.c
[arm64-v8a] Compile : SDL3 <= SDL_surface.c
[arm64-v8a] Compile : SDL3 <= SDL_video.c
[arm64-v8a] Compile : SDL3 <= SDL_video_unsupported.c
[arm64-v8a] Compile : SDL3 <= SDL_vulkan_utils.c
[arm64-v8a] Compile : SDL3 <= SDL_yuv.c
[arm64-v8a] Compile : SDL3 <= SDL_androidclipboard.c
[arm64-v8a] Compile : SDL3 <= SDL_androidevents.c
[arm64-v8a] Compile : SDL3 <= SDL_androidgl.c
[arm64-v8a] Compile : SDL3 <= SDL_androidkeyboard.c
[arm64-v8a] Compile : SDL3 <= SDL_androidmessagebox.c
[arm64-v8a] Compile : SDL3 <= SDL_androidmouse.c
[arm64-v8a] Compile : SDL3 <= SDL_androidpen.c
[arm64-v8a] Compile : SDL3 <= SDL_androidtouch.c
[arm64-v8a] Compile : SDL3 <= SDL_androidvideo.c
[arm64-v8a] Compile : SDL3 <= SDL_androidvulkan.c
[arm64-v8a] Compile : SDL3 <= SDL_androidwindow.c
[arm64-v8a] Compile : SDL3 <= yuv_rgb_lsx.c
[arm64-v8a] Compile : SDL3 <= yuv_rgb_sse.c
[arm64-v8a] Compile : SDL3 <= yuv_rgb_std.c
[arm64-v8a] Compile : cpufeatures <= cpu-features.c
[arm64-v8a] StaticLibrary : libcpufeatures.a
[arm64-v8a] SharedLibrary : libSDL3.so
[arm64-v8a] Compile : main <= testgles.c
[arm64-v8a] SharedLibrary : libmain.so

C++ build system [build] failed while executing:
/home/howie/Android/Sdk/ndk/27.0.12077973/ndk-build
NDK_PROJECT_PATH=null
APP_BUILD_SCRIPT=/home/howie/Development/SDL/build/org.libsdl.testgles/app/jni/Android.mk
NDK_APPLICATION_MK=/home/howie/Development/SDL/build/org.libsdl.testgles/app/jni/Application.mk
APP_ABI=arm64-v8a
NDK_ALL_ABIS=arm64-v8a
NDK_DEBUG=1
NDK_OUT=/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj
NDK_LIBS_OUT=/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/lib
APP_PLATFORM=android-19
SDL3
main
from /home/howie/Development/SDL/build/org.libsdl.testgles/app
ld.lld: error: undefined symbol: SDLTest_CommonCreateState

referenced by testgles.c:113 (app/jni/src/testgles.c:113)
/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)

ld.lld: error: undefined symbol: SDLTest_CommonArg

referenced by testgles.c:121 (app/jni/src/testgles.c:121)
/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)

ld.lld: error: undefined symbol: SDLTest_CommonLogUsage

referenced by testgles.c:148 (app/jni/src/testgles.c:148)
/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)

ld.lld: error: undefined symbol: SDLTest_CommonInit

referenced by testgles.c:170 (app/jni/src/testgles.c:170)
/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)

ld.lld: error: undefined symbol: SDLTest_CommonEvent

referenced by testgles.c:297 (app/jni/src/testgles.c:297)
/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(SDL_main)

ld.lld: error: undefined symbol: SDLTest_CommonQuit

referenced by testgles.c:45 (app/jni/src/testgles.c:45)
/home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/objs-debug/main/testgles.o:(quit)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/howie/Android/Sdk/ndk/27.0.12077973/build/core/build-binary.mk:661: /home/howie/Development/SDL/build/org.libsdl.testgles/app/build/intermediates/cxx/Debug/4o424436/obj/local/arm64-v8a/libmain.so] Error 1

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to Command-Line Interface Reference in the Gradle documentation.

BUILD FAILED in 19s
16 actionable tasks: 16 executed

What I’ve learned is that if you add ../src/test/* to the test, it will build and run on an Android.
Below is the final command. It would be great is someone couls add the below to the README-android.md.
./create-android-project.py org.libsdl.testgles ../test/testgles.c ../src/test/*