Added explanation to override fopen if using external headers like dr_mp3

Maicon Santana
2026-02-25 14:24:00 +00:00
parent 82c58d7809
commit ec203fd37b

@ -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 <stdio.h>
> // 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].**