-
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
Linking OpenBlas in AndroidStudio project #1830
Comments
Do you use |
No I'm not, can you send me the link to the page that suggested we use -lto/-flto? I don't currently see that in the links I found. |
Link where problem was attributed to using lto (but older ndk, probably older compiler as well) |
Compiling with -flto doesn't get rid of the errors but it changes some of them. C:/Users/Jeff/AppData/Local/Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld: error: C:/Users/Jeff/Documents/neurable-library/libs/OpenBLAS/libopenblas.a:1:31: syntax error, unexpected $end |
How did you build openblas? What EIGEN options regarding BLAS and MKL are set? |
I figured out the unexpected $end error, I needed to clear my CMake cache to make sure it was pointing to the right library, which it wasn't before. I still get the undefined reference to dgemm_, dgemv_, dtrsm_, etc. errors. I included cblas.h as was said in other posts but that didn't work. My OpenBlas is only compiled with Blas not Lapack, is Lapack necessary for Eigen? Also the macro I am using is EIGEN_USE_BLAS |
DGEMM,DGEMV and DTRSM are BLAS functions so no need for LAPACK. There is the (very slight) possibility that the symbols in your build of libopenblas.a do not have the trailing underscore, |
When I ran nm -s libopen libopenblas_armv7-r0.3.4.dev.a I got this file. I see symbols like dtrsm_LNUU or like dgemv_n but not exactly dtrsm_. |
That list looks like a partial library - the cblas interfaces are there, but strangely none of the blas ones generated from the interface directory - there should be e.g. a line "dgemm_ in dgemm.o" followed later by the detailed section for dgemm.o showing "T dgemm_" . Probably best to redo the build and see if there are any errors for the |
What is your target hardware by the way ? In #1823 you were building OpenBLAS for ARMV8, but here it seems to me you have the libopenblas built for 32bit ARMV7 and your NDK toolchain appears to be for Android on x86_64 ? |
Yeah I changed it to ARMV7, I'm double checking my toolchain to make sure it's not still using x86_64. |
Eigen needs fortran BLAS, not CBLAS (NO_CBLAS=1) |
In your first post, the toolchain has names ending in x86_64-linux-android where your toolchain from #1823 initially had aarch64-linux-android (and probably something like arm-linux-androideabi in the end). |
Eigen provides cblas.h and CBLAS interface over any F77 BLAS library. It is best to disable surplus CBLAS interface of OpenBLAS to avoid confusing more compilers. One can say there are no issues with the interface since it is deliberately absent from the library you compiled. |
Guess the wording of the associated comment in Makefile.rule can be misleading as it only mentions building without a FORTRAN compiler (where the actual issue back in #279 was with some of the tests) but not interfacing with other software like Eigen that makes BLAS rather than CBLAS calls. |
EIGEN will provide own cblas.h, that will override L1 and for small matrices also L2 and L3 |
Okay I will re-build this again on Linux using the OpenBlas Android tutorial with Fortran. Shall I close this issue and make a new issue if I have problems with that or should I keep this thread open for now? |
You should not even need FORTRAN for building the BLAS interface, the issue prompting creation of the ONLY_CBLAS option is/was only that the related post-build tests require FORTRAN - but these tests are not run in cross-compilation builds anyway. |
I'm sorry I still don't think I quite understand. I need to turn off the ONLY_CBLAS option but I don't need to build OpenBLAS with FORTRAN? |
All the BLAS in OpenBLAS is written in C and assembly, you should only need FORTRAN for the LAPACK part and some of the included tests (which as mentioned are only run in native builds). |
Okay well then I need to figure out a different solution for my build, because turning off the ONLY_CBLAS option causes more errors. |
Errors in the OpenBLAS build, or errors when linking with Eigen and your code ? |
Errors in the OpenBLAS build, I'm currently not at the computer where I built OpenBLAS so once I get there I can send the build.log. |
There is no need for build log. You need to build with NO_CBLAS option. That will use C compiler to provide F77-only BLAS library interface for use from EIGEN. |
Yes I'm sorry that's what I meant. I am using the NO_CBLAS option and I still get errors saying command not found for -marm, which I am debugging now. |
Sounds as if you still have an x86 compiler involved instead of the arm compiler from the toolchain. |
Sorry for the late response but thank you Martin, you were correct. I was able to rebuild open BLAS on linux for ARMV7. |
Hello,
I am having issues with linking the OpenBlas library to my Android Studio project. I am getting these type of errors:
C:/Users/Jeff/AppData/Local/Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld: error: C:/Users/Jeff/Documents/neurable-library/libs/OpenBLAS/libopenblas.a:1:31: syntax error, unexpected $end
C:/Users/Jeff/AppData/Local/Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld: error: C:/Users/Jeff/Documents/neurable-library/libs/OpenBLAS/libopenblas.a: not an object or archive
C:/Users/Jeff/AppData/Local/Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld: error: C:/Users/Jeff/Documents/neurable-library/libs/OpenBLAS/libopenblas.a:1:31: syntax error, unexpected $end
C:/Users/Jeff/AppData/Local/Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld: error: C:/Users/Jeff/Documents/neurable-library/libs/OpenBLAS/libopenblas.a: not an object or archive
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h:106: error: undefined reference to 'dgemm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h:106: error: undefined reference to 'dgemm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixVector_BLAS.h:120: error: undefined reference to 'dgemv_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixVector_BLAS.h:120: error: undefined reference to 'dgemv_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h:141: error: undefined reference to 'dtrsm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h:87: error: undefined reference to 'dtrsm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h:141: error: undefined reference to 'dtrsm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h:102: error: undefined reference to 'dsymv_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixVector_BLAS.h:120: error: undefined reference to 'dgemv_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixVector_BLAS.h:120: error: undefined reference to 'dgemv_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h:87: error: undefined reference to 'dtrsm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h:106: error: undefined reference to 'dgemm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h:293: error: undefined reference to 'dtrmm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h:106: error: undefined reference to 'dgemm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h:183: error: undefined reference to 'dtrmm_'
C:/Users/Jeff/Documents/neurable-library/include\Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h:183: error: undefined reference to 'dtrmm_'
I am using Windows 10 with API Level 22, the OpenBlas library was built on linux as a .a and I'm trying to get Eigen to use OpenBlas.
The text was updated successfully, but these errors were encountered: