llama.cpp
llama.cpp copied to clipboard
Android build fails with ld: error: undefined symbol: aligned_alloc
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [/] I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- [/] I carefully followed the README.md.
- [/] I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
- [/] I reviewed the Discussions, and have a new bug or useful enhancement to share.
Expected Behavior
Compile for android.
Current Behavior
An error message when running make
[100%] Linking CXX executable ../../bin/main
ld: error: undefined symbol: aligned_alloc
>>> referenced by ggml.c:3067 (/Users/blewandowski/repositories/llama.cpp/ggml.c:3067)
>>> ggml.c.o:(ggml_init) in archive ../../libllama.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [bin/main] Error 1
make[2]: *** [examples/main/CMakeFiles/main.dir/all] Error 2
make[1]: *** [examples/main/CMakeFiles/main.dir/rule] Error 2
make: *** [main] Error 2
Environment and Context
Mac OSX M2 Air
Installed latest NDK, exported as NDK=/Users/blewandowski/Library/Android/sdk/ndk/25.2.9519653 then followed instructions in the README
$ mkdir build-android $ cd build-android $ export NDK=<your_ndk_directory> $ cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23 -DCMAKE_C_FLAGS=-march=armv8.4a+dotprod .. $ make
We need to pass -std=c11
to compiler. Not sure how that is done on Android.
I'd like to note that this is compiled on my Mac, for a different architecture and system => Android.
Try if using this helps:
-DCMAKE_C_FLAGS="-std=c11 -march=armv8.4a+dotprod"
@prusnak new command is
cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23 -DCMAKE_C_FLAGS="-std=c11 -march=armv8.4a+dotprod" ..
but the same error is shown
Try building the master
branch now - it contains https://github.com/ggerganov/llama.cpp/commit/aa485cee334e84437e21681c14b6f80b65876d8b which replaces aligned_alloc
with posix_memalign
.
It looks like the code compiles now, I'll verify if I can get it working on my phone now. Cheers!
On Sat, Apr 15, 2023 at 11:36 PM Pavol Rusnak @.***> wrote:
Try building the master branch now - it contains aa485ce https://github.com/ggerganov/llama.cpp/commit/aa485cee334e84437e21681c14b6f80b65876d8b which replaces aligned_alloc with posix_memalign.
— Reply to this email directly, view it on GitHub https://github.com/ggerganov/llama.cpp/issues/973#issuecomment-1509982788, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFJABKIN4JTUEU2M5PN4U3XBMIFNANCNFSM6AAAAAAW6WVCCU . You are receiving this because you authored the thread.Message ID: @.***>