Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build fails with ld: error: undefined symbol: aligned_alloc #973

Closed
BartlomiejLewandowski opened this issue Apr 14, 2023 · 6 comments

Comments

@BartlomiejLewandowski
Copy link

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

@prusnak
Copy link
Collaborator

prusnak commented Apr 14, 2023

We need to pass -std=c11 to compiler. Not sure how that is done on Android.

@BartlomiejLewandowski
Copy link
Author

I'd like to note that this is compiled on my Mac, for a different architecture and system => Android.

@prusnak
Copy link
Collaborator

prusnak commented Apr 14, 2023

Try if using this helps:

-DCMAKE_C_FLAGS="-std=c11 -march=armv8.4a+dotprod"

@BartlomiejLewandowski
Copy link
Author

@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

@prusnak
Copy link
Collaborator

prusnak commented Apr 15, 2023

Try building the master branch now - it contains aa485ce which replaces aligned_alloc with posix_memalign.

@BartlomiejLewandowski
Copy link
Author

BartlomiejLewandowski commented Apr 16, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants