mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

mimalloc with NDK

Open haroel opened this issue 7 months ago • 1 comments

I have compiled the mimalloc static library myself, using the v2.2.3 version branch. Here are my NDK cmake build settings:

SET ANDROID_NDK=D:\Android\SDK\ndk\25.1.8937393
SET CMAKE_PATH=cmake
SET ANDROID_PLATFORM=android-24
SET ANDROID_TOOLCHAIN=clang

....
    %CMAKE_PATH% .. ^
        -G "Ninja" ^
        -DCMAKE_TOOLCHAIN_FILE="%ANDROID_NDK%\build\cmake\android.toolchain.cmake" ^
        -DANDROID_ABI=!ABI! ^
        -DANDROID_PLATFORM=%ANDROID_PLATFORM% ^
        -DANDROID_TOOLCHAIN=%ANDROID_TOOLCHAIN% ^
        -DCMAKE_BUILD_TYPE=Release ^
        -DMI_BUILD_SHARED=OFF ^
        -DMI_BUILD_STATIC=ON ^
        -DMI_BUILD_TESTS=OFF ^

get libmimalloc.a , put it to my android project, compile error


C:\Windows\system32\cmd.exe /C "cd . && D:\Android\SDK\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --sysroot=D:/Android/SDK/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -fno-rtti -fexceptions -fsigned-char -Werror=return-type -fno-limit-debug-info  -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments    -Xlinker --dependency-file -Xlinker CMakeFiles\xxx.dir\link.d -shared -Wl,-soname,libarda.so -o E:\gitlab\xxx\proj.android\app\build\intermediates\cxx\Debug\1t5z5v5j\obj\arm64-v8a\libarda.so @CMakeFiles\arda.rsp && cd ."

ld: error: undefined symbol: stdout
>>> referenced by options.c:442 (E:/github/mimalloc/src/options.c:442)
>>>               options.c.o:(_mi_fputs) in archive E:/gitlab/xxx/external/android/arm64-v8a/libmimalloc.a
>>> referenced by options.c:442 (E:/github/mimalloc/src/options.c:442)
>>>               options.c.o:(_mi_fputs) in archive E:/gitlab/xxx/external/android/arm64-v8a/libmimalloc.a
>>> referenced by options.c:442 (E:/github/mimalloc/src/options.c:442)
>>>               options.c.o:(_mi_fprintf) in archive E:/gitlab/xxx/external/android/arm64-v8a/libmimalloc.a
>>> referenced 1 more times

How can i do with this?

Do you have any recommended compilation configuration settings?

haroel avatar Apr 27 '25 08:04 haroel

Mmm, it looks like you are not linking with the C standard library (which contains stdout) ? I am not very familiar with Android though so perhaps others can pitch in

daanx avatar May 14 '25 01:05 daanx