-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
I trying to build for Android in Mac OS M2. My targets are armeabi-v7a and arm64-v8a.
I get this error
Mac/aarch64/libllama.so is incompatible with aarch64linux
What is the reason for this error?
MY gradle:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
val jllamaLib = file("java-llama.cpp")
// Execute "mvn compile" if folder target/ doesn't exist at ./java-llama.cpp/
if (!file("$jllamaLib/target").exists()) {
exec {
commandLine = listOf("mvn", "compile")
workingDir = file("java-llama.cpp/")
}
}
namespace = "com.example.javallama"
compileSdk = 34
defaultConfig {
applicationId = "com.example.javallama"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// Specify ABI filters for C++ builds
ndk {
abiFilters.add("armeabi-v7a")
abiFilters.add("arm64-v8a")
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.22.1"
}
}
// Declare c++ sources
externalNativeBuild {
cmake {
path = file("$jllamaLib/CMakeLists.txt")
version = "3.22.1"
}
}
buildFeatures {
viewBinding = true
}
sourceSets {
named("main") {
// Add source directory for java-llama.cpp
java.srcDir("$jllamaLib/src/main/java")
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
Entire stacktrace :
> Task :app:assembleDebugAndroidTest UP-TO-DATE
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/rageshantonyd/AndroidStudioProjects/java_llama/app/.cxx/Debug/43sv3z46/arm64-v8a'
[1/1] Linking CXX shared library /Users/rageshantonyd/AndroidStudioProjects/java_llama/app/java-llama.cpp/src/main/resources/de/kherud/llama/Mac/aarch64/libjllama.so
FAILED: /Users/rageshantonyd/AndroidStudioProjects/java_llama/app/java-llama.cpp/src/main/resources/de/kherud/llama/Mac/aarch64/libjllama.so
: && /Users/rageshantonyd/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --sysroot=/Users/rageshantonyd/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-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-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libjllama.so -o /Users/rageshantonyd/AndroidStudioProjects/java_llama/app/java-llama.cpp/src/main/resources/de/kherud/llama/Mac/aarch64/libjllama.so CMakeFiles/jllama.dir/src/main/cpp/jllama.cpp.o _deps/llama.cpp-build/common/libcommon.a /Users/rageshantonyd/AndroidStudioProjects/java_llama/app/java-llama.cpp/src/main/resources/de/kherud/llama/Mac/aarch64/libllama.so -latomic -lm && :
ld: error:
/Users/rageshantonyd/AndroidStudioProjects/java_llama/app/java-llama.cpp/src/main/resources/de/kherud/llama/Mac/aarch64/libllama.so is incompatible with aarch64linux
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
C++ build system [build] failed while executing:
/Users/rageshantonyd/Library/Android/sdk/cmake/3.22.1/bin/ninja \
-C \
/Users/rageshantonyd/AndroidStudioProjects/java_llama/app/.cxx/Debug/43sv3z46/arm64-v8a \
ggml_shared \
jllama \
llama
from /Users/rageshantonyd/AndroidStudioProjects/java_llama/app
Please help me
Metadata
Metadata
Assignees
Labels
No labels