From eee86dd7c9b7b71aad131f56ebeb9ad6dd05ca69 Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:37:57 +0100 Subject: [PATCH] [build][CMake] Fix cmake configuration issue for Android (#4671) * fix cmake configuration issue for Android * review comment --- cmake/LibraryConfigurations.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index fb789830..00dda033 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -69,6 +69,14 @@ elseif (${PLATFORM} MATCHES "Android") set(CMAKE_POSITION_INDEPENDENT_CODE ON) list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + + # NOTE: We remove '-Wl,--no-undefined' (set by default) as it conflicts with '-Wl,-undefined,dynamic_lookup' needed + # for compiling with the missing 'void main(void)' declaration in `android_main()`. + # We also remove other unnecessary or problematic flags. + + string(REPLACE "-Wl,--no-undefined -Qunused-arguments" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + string(REPLACE "-static-libstdc++" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup") find_library(OPENGL_LIBRARY OpenGL)