From a91bc5b23eb124a564be1c2c9653c4115e01663b Mon Sep 17 00:00:00 2001 From: Massimo Fraschetti Date: Mon, 6 Apr 2026 18:06:06 +0200 Subject: [PATCH] fix(webrtc-sys): replace __sF with POSIX fdopen for NDK 28+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The __sF libc internal symbol was removed in Android NDK 28. The previous workaround in android.cpp referenced &__sF[1] and &__sF[2] to force-define stdout/stderr, causing compilation errors with NDK 28 and 29: src/android.cpp:34:17: error: use of undeclared identifier '__sF' 34 | FILE *stdout = &__sF[1]; Use POSIX fdopen(STDOUT_FILENO/STDERR_FILENO) instead — works across all NDK versions and avoids reaching into libc internals. --- webrtc-sys/src/android.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/webrtc-sys/src/android.cpp b/webrtc-sys/src/android.cpp index 8a83ac1ae..210e9a606 100644 --- a/webrtc-sys/src/android.cpp +++ b/webrtc-sys/src/android.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include "api/video_codecs/video_decoder_factory.h" @@ -27,14 +28,16 @@ #include "sdk/android/native_api/jni/scoped_java_ref.h" #include "sdk/android/src/jni/jni_helpers.h" -// When we compiling the examples app on Android results in errors -// indicating that the `stderr` and `stdout` symbols cannot be found; -// so we need to force hardcoding them to point to the system symbols. +// When compiling the examples app on Android, the linker complains that +// `stdout` and `stderr` symbols cannot be found. The previous workaround +// referenced `__sF`, but that symbol was removed in NDK 28+. +// Use POSIX `fdopen()` with the standard file descriptors instead — works +// across all NDK versions. #undef stdout -FILE *stdout = &__sF[1]; +FILE *stdout = fdopen(STDOUT_FILENO, "w"); #undef stderr -FILE *stderr = &__sF[2]; +FILE *stderr = fdopen(STDERR_FILENO, "w"); namespace livekit_ffi {