-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 NDK build with the ONLY_CBLAS=0 argument #4952
Comments
Does it build when you leave out the entire |
No, the build also fails if I leave out the entire |
Ok, there seems to be something "historically" weird with the CMake build - contrary to the Makefile settings, it uses
(and for NDK r27 one also needs to increase the ancient cmake_minimum_required in CMakeLists.txt to at least 3.3.0 to avoid some confusing errors - android/ndk#2032 |
Ok, to let you know, the build was successfully completed by changing the argument you mentioned with the another Android target version. I targeted I also confirmed that it works without any linking errors as a third party. Thank you once again, and I'll share the build script here to prevent others from experiencing the same difficulties: #!/bin/bash
set -e
NDK_TARGET_VERSION=25.1.8937393
TARGET_ANDROID_PLATFORM=android-27
ABIS=("arm64-v8a" "armeabi-v7a" "x86" "x86_64")
if [ "$(uname)" == 'Darwin' ]; then
NDK_DIR="$HOME/Library/Android/sdk/ndk"
else
NDK_DIR="$HOME/Android/Sdk/ndk"
fi
if [ ! -d "$NDK_DIR" ]; then
echo "-- Cannot find NDK directory: $NDK_DIR"
exit 1
fi
NDK_PATH="$NDK_DIR/$NDK_TARGET_VERSION/build/cmake/android.toolchain.cmake"
if [ ! -f "$NDK_PATH" ]; then
echo "-- Cannot find NDK toolchain: $NDK_PATH, Please download NDK $NDK_TARGET_VERSION first"
exit 1
fi
echo "-- Android toolchain file has found: $NDK_PATH"
if [ -z "$MAX_JOBS" ]; then
if [ "$(uname)" == 'Darwin' ]; then
MAX_JOBS=$(sysctl -n hw.ncpu)
else
MAX_JOBS=$(nproc)
fi
fi
for ABI in "${ABIS[@]}"
do
# Build directory for the current ABI
BUILD_DIR="build/android_$ABI"
# Remove existing build directory if it exists
if [ -d "$BUILD_DIR" ]; then
rm -rf $BUILD_DIR
fi
# Create build directory
mkdir -p $BUILD_DIR
CMAKE_ARGS=()
if [ -x "$(command -v ninja)" ]; then
CMAKE_ARGS+=("-GNinja")
fi
CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release")
CMAKE_ARGS+=("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF")
CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=$BUILD_DIR/install")
CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=$NDK_PATH")
CMAKE_ARGS+=("-DANDROID_PLATFORM=$TARGET_ANDROID_PLATFORM")
CMAKE_ARGS+=("-DANDROID_ABI=$ABI")
CMAKE_ARGS+=("-DBUILD_STATIC_LIBS=ON")
CMAKE_ARGS+=("-DBUILD_SHARED_LIBS=OFF")
CMAKE_ARGS+=("-DBUILD_TESTING=OFF")
# CMAKE_ARGS+=("-DONLY_CBLAS=0")
CMAKE_ARGS+=("-DBUILD_WITHOUT_CBLAS=0")
if [ $ABI == "arm64-v8a" ]; then
CMAKE_ARGS+=("-DTARGET=CORTEXA57")
CMAKE_ARGS+=("-DBINARY=64")
elif [ $ABI == "armeabi-v7a" ]; then
CMAKE_ARGS+=("-DTARGET=ARMV7")
elif [ $ABI == "x86" ]; then
CMAKE_ARGS+=("-DTARGET=ATOM")
elif [ $ABI == "x86_64" ]; then
CMAKE_ARGS+=("-DTARGET=ATOM")
CMAKE_ARGS+=("-DBINARY=64")
fi
# Run CMake configuration
cmake -S . -B $BUILD_DIR "${CMAKE_ARGS[@]}"
# Build and install
cmake --build $BUILD_DIR --target install -- "-j${MAX_JOBS}"
done
|
Hello, I have read through all of #2005 and confirmed that it can be successfully built using the NDK r25 cmake toolchain along with the
ONLY_CBLAS=1
parameter. Currently, I am trying to buildOpenBLAS-r0.3.28
as a dynamic library for the Android environment, and my host environment is Apple Silicon macOS right now.However, when I set ONLY_CBLAS=0 for the Android build, I end up with undefined symbol errors for functions like cabsf at the end of the build.
If I build with
ONLY_CBLAS=0
on macOS Apple Clang instead of using the Android toolchain, the build completes smoothly though. (And as I mentioned earlier, passing theONLY_CBLAS=1
parameter in Android allows it to build successfully.)I would appreciate it if somebody could explain why this is not working well.
The text was updated successfully, but these errors were encountered: