-
Notifications
You must be signed in to change notification settings - Fork 1.6k
How to link OpenBlas for armv7 by CMake in Android Studio? #1280
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
Comments
Care to mention it is intellij or eclipse android studio? |
I understand you have already built the library.
Change STATIC to SHARED if you built OpenBLAS as a shared library. |
@nannanmath did xsacha's suggestion solve the problem for you ? |
Hi @martin-frbg, I followed xsacha's suggestion but i cannot add cblas.h in my android project. The Library gets added but i cannot access any functions |
target_include_directories(${PROJECT_NAME} PRIVATE /path/to/blasinclude) |
This statement is causing External Native Build Issues. I guess the include path might be incorrect, I've tried the following:
|
Well you said you weren't able to find cblas.h in the include, so you just need to add that path. |
The following directories have cblas.h in them and I've tried both of them and still the issue persisted
|
What's the issue and what's the #include line? |
Usually programs that use BLAS keep their own BLAS headers. It shouldn't need to include anything from openblas. It's a standard API. |
In the CMakeLists.txt file I added the target_include_directories as you had mentioned. The path I have added is as follows:
Now in Android Studio when I try to build the project it causes the gradle sync to fail with the messages saying "External Native Build Issues" at the target_include_directories line in CMakeLists.txt |
Something is not clear to me guys. (I'm trying to use DLIB with OpenBlas on Android).
I have two questions:
Thanks in advance. |
please do not overtake unrelated threads. Dlib still has no use of any BLAS. |
hm, I read the old dlib issue as "detecting blas function availability used to be broken in the dlib build but should be fixed now". @Mik-el do you get any compilation errors from Visual Studio, and do you see any libopenblas files built anywhere (maybe it is only doing the shared one by default)? |
@brada4 Sorry, maybe I posted in the wrong thread. But are you sure DLib can't use BLAS? Because someone resulted to do it, also benchmarking the difference. @martin-frbg Compiling everything from Visual Studio seems to work since it returns: "Compilation: 25 completed, 0 failed, 0 updated, 0 ignored". |
You build cross-build openblas, then use cmake-gui to import that to a cross-build of dlib? |
Android Studio compiles DLib into |
You need to build openblas with android NDK to import or link it from other android library. Then dlib build system should be able to detect it. Typically you get openblas as an .a file - static library and .so file - dynamic library, and cmake will try to find compatible functions under these names in there. You can check manually with |
Thank you @brada4. I was only going off track with Visual Studio! That's why the compilation didn't work on Windows:
As you can see it uses To make Dlib detect OpenBlas I opened my OpenBLASConfig.cmake and I added I then compiled Dlib with this script, the compilation is OK, but OpenBlas doesn't get detected:
(Basically it just suggests installing OpenBlas compiled .deb packages, but they won't work, since it's not OpenBlas for cross-compilation). I repeated all the compilation steps on both Ubuntu and a Debian-based distro, but nothing... How can I make Dlib detect OpenBlas? Thanks for any help |
That is how cmake files of dlib detects BLAS under cross-build scenario. |
Not sure if cross-build has anything to do with this. From https://github.com/davisking/dlib/blob/dd1ec1fcff9479b00b233755aa673c028004d96d/dlib/cmake_utils/find_blas.cmake#L186 |
@martin-frbg thank you. I applied your last 2 suggestions. Still Dlib can't detect OpenBlas.
export NDK=/home/user/Android/Sdk/ndk/21.4.7075529
echo "Set NDK to $NDK"
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
echo "Set TOOLCHAIN to $TOOLCHAIN"
echo
echo " *** make clean"
echo
make clean
echo
echo " *** make for ARMV8"
echo
make \
TARGET=ARMV8 \
ONLY_CBLAS=1 \
CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang \
AR=$TOOLCHAIN/bin/aarch64-linux-android-ar \
HOSTCC=gcc \
-j4
echo
echo "*************************"
echo " *** make install start"
echo "*************************"
echo
#sudo make install
sudo make install DESTDIR=/home/user/Downloads/OpenBlasInstall
echo
echo "*************************"
echo " *** make install finish "
echo "*************************"
echo terminal outputs this: compileOpenBlas.pdf
(Meanwhile, I'm also trying with the Termux approach, just knowing that there's no Make and I'll have to do |
Can you attach searchable plaintext instead of bitmap in pdf? |
pdf is searchable for me (at least the dlibCompileDebugOn one), but less informative than I had hoped. Search for openblas starts on page 633 but apoears to be restricted to subdirectories of the ndk install path |
On page 541 it finds Openblas 0.3.13ds in NDK paths for x86_64,
So there is some aarch64 missed somewhere in command lines. |
Thanks for your replies as always. I attached the script as text. (I run it from the source dir |
Dear, cmake with debug on PDF page 541 detects openblas x86_64 debian 0.3.13ds as a valid lapack for your cross-compilation. |
It is inherent problem with cmake cross-build. qt or libreoffice minor dependencies (not only BLAS) suffer same way, you need to either disable minor dependency (likely your intent is not dropping OpenBLAS) or uninstall native package. There is nothing openblas could do better. |
I compile OpenBlas according to https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android. I also find a section about linking:https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android#linking-openblas-0219-and-earlier-for-armv7. Howerver, I use cmake in Android Studio, I want to know how to set them in CMakeLists.txt. Thanks.
The text was updated successfully, but these errors were encountered: