From ec203fd37b0713d82f305365c15d2442dbc32e40 Mon Sep 17 00:00:00 2001 From: Maicon Santana Date: Wed, 25 Feb 2026 14:24:00 +0000 Subject: [PATCH] Added explanation to override fopen if using external headers like `dr_mp3` --- Working-for-Android.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Working-for-Android.md b/Working-for-Android.md index 61c7d54..58a23d1 100644 --- a/Working-for-Android.md +++ b/Working-for-Android.md @@ -289,6 +289,24 @@ when compiling,if report "fatal error: 'asm/types.h' file not found ", you need copy "asm-generic" and renamed as "asm". (the path "D:\Program_Files\android_sdk\ndk\25.0.8775105\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\asm-generic") +> [!NOTE] +> If you need to load files using a external header like `dr_mp3` please consider overriding the `fopen` to `android_fopen` using a linker wrap. +> 1. **Using Make** +> - `-Wl,--wrap=fopen` +> 2. **Using CMake** +> - `target_link_options(${APP_LIB_NAME} PRIVATE "-Wl,--wrap=fopen")` +> - If you need to override the fopen using linker wrap here is the implementation sample: +> ```c99 +> #include +> // This makes a signature for the android_fopen that will be implemented on rcore_android.c +> extern FILE *android_fopen(const char *fileName, const char *mode); +> +> // The linker wrap will override the function on it to __wrap_(name) +> FILE* __wrap_fopen(const char* path, const char* mode) { +> // Call the rcore_android android_fopen function +> return android_fopen(path, mode); +> } +> ``` **If you have any doubt, [just let me know][raysan5].**