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 3509

Summary: Cmake for android not work
Product: SDL Reporter: tower120
Component: buildAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus, tower120
Version: 2.0.5   
Hardware: ARM   
OS: Android (All)   

Description tower120 2016-12-07 19:59:43 UTC
in CMakeLists.txt you include filesystem twice (for UNIX and for ANDROID).

Around 970-980 line there is no guard for android. Should be,probably, like this:

---------
elseif(UNIX AND NOT APPLE)

  ...

  # Around 970-980 line :
  if(SDL_FILESYSTEM)
    if(NOT ANDROID)
        set(SDL_FILESYSTEM_UNIX 1)
        file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c)
        set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
        set(HAVE_SDL_FILESYSTEM TRUE)
    endif()
  endif()

  ...
---------

Also, you don't link with GLES. I'm not sure about this, but for me this solve the link problem. I manually added (around line 770):
---------
if(ANDROID)

  ...

  list(APPEND EXTRA_LDFLAGS "-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")

  # FIXME: Added manually
  list(APPEND EXTRA_LDFLAGS "-ldl", "-lGLESv1_CM", "-lGLESv2", "-llog", "-landroid")
endif()
---------

N.B. I see that you rise SDL_VIDEO_OPENGL_ES2 flag, but it seems that you not use it for now.


When building from Android Studio (which use clang, by default) it is also necessary to add following cflags:
"-Wa,-mimplicit-it=thumb", "-DGL_GLEXT_PROTOTYPES", "-DHAVE_PTHREADS"
Comment 1 Ryan C. Gordon 2017-06-06 17:45:57 UTC
This should all be fixed in revision control now, mostly by

https://hg.libsdl.org/SDL/rev/a4c90708251c

--ryan.