Skip to content

Commit eee86dd

Browse files
authored
[build][CMake] Fix cmake configuration issue for Android (#4671)
* fix cmake configuration issue for Android * review comment
1 parent b554b53 commit eee86dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmake/LibraryConfigurations.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ elseif (${PLATFORM} MATCHES "Android")
6969
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
7070
list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
7171
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
72+
73+
# NOTE: We remove '-Wl,--no-undefined' (set by default) as it conflicts with '-Wl,-undefined,dynamic_lookup' needed
74+
# for compiling with the missing 'void main(void)' declaration in `android_main()`.
75+
# We also remove other unnecessary or problematic flags.
76+
77+
string(REPLACE "-Wl,--no-undefined -Qunused-arguments" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
78+
string(REPLACE "-static-libstdc++" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
79+
7280
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")
7381

7482
find_library(OPENGL_LIBRARY OpenGL)

0 commit comments

Comments
 (0)