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

win7+mingw+android ndk #1524

Closed
luwang-epic opened this issue Apr 16, 2018 · 12 comments
Closed

win7+mingw+android ndk #1524

luwang-epic opened this issue Apr 16, 2018 · 12 comments

Comments

@luwang-epic
Copy link

I am going to compile openblas for android in windows 7. To make in windows 7, I install mingw and msys.
I followed https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android to build armv8 with clang.
I

export NDK_BUNDLE_DIR=D:\\software\\android-ndk-r16b
export PATH=$PATH:${NDK_BUNDLE_DIR}\\my-android-toolchain\\bin
export LDFLAGS="-L${NDK_BUNDLE_DIR}\\my-android-toolchain\\lib\\gcc\\aarch64-linux-android\\4.9.x -lm" 
export CLANG_FLAGS="-target aarch64-linux-android --sysroot ${NDK_BUNDLE_DIR}\\my-android-toolchain\\sysroot\\usr\\include -gcc-toolchain ${NDK_BUNDLE_DIR}\\my-android-toolchain\\bin"
make TARGET=ARMV8 AR=ar CC="clang ${CLANG_FLAGS}" NOFORTRAN=1 NO_LAPACK=1 HOSTCC=gcc

Error happened:
image

stdio.h is in D:\software\android-ndk-r16b\my-android-toolchain\sysroot\usr\include
I included it in CLANG_FLAGS, why this happened?

@martin-frbg
Copy link
Collaborator

Does it work when you set sysroot to D:\software\android-ndk-r16b\my-android-toolchain\sysroot,
without the usr\include (and also define the gcc-toolchain without the \bin at the end) ?

@luwang-epic
Copy link
Author

I tried ,and new error occured:

$ make TARGET=ARMV8 AR=ar CC="clang ${CLANG_FLAGS}" ONLY_CBLAS=1 HOSTCC=gcc
ln: creating symbolic link `libopenblas.a' to `libopenblas_armv8p-r0.3.0.dev.a':
 No such file or directory
make: [libs] Error 1 (ignored)
d:\software\Mingw\bin\ar.exe: creating ../libopenblas_armv8p-r0.3.0.dev.a
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find crtbegin_dynamic.o: No such file or directory
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find -lm
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find -lgcc
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find -ldl
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find -lc
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find -lgcc
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find -ldl
d:\software\android-ndk-r16b\my-android-toolchain\bin\aarch64-linux-android-ld:
cannot find crtend_android.o: No such file or directory
clang50.exe: error: linker command failed with exit code 1 (use -v to see invoca
tion)
make[1]: *** [../libopenblas_armv8p-r0.3.0.dev.so] Error 1
make: *** [shared] Error 2

@martin-frbg
Copy link
Collaborator

From #1632 (comment) this may actually have been a bug in NDK r16b

@danielcjacobs
Copy link

danielcjacobs commented Jan 12, 2022

I get this same error trying to build on Fedora 34 with NDK r21e and current OpenBLAS version (0.3.19 I believe)

@martin-frbg
Copy link
Collaborator

can you try with the current ndk (23b I believe), just in case this was a temporary regression ?

@danielcjacobs
Copy link

danielcjacobs commented Jan 12, 2022

Yeah, the paths are a bit different for 23b, so I'm trying to make sure I have them correct. 23b doesn't seem to have all the binaries that the previous versions have (e.g. seems to have removed aarch64-linux-android-strip, aarch64-linux-android-ar, aarch64-linux-android-ld, and aarch64-linux-android-ranlib). I don't see these in the r24 beta either.

@danielcjacobs
Copy link

danielcjacobs commented Jan 12, 2022

Also, versions after r22b don't seem to have libgcc. Not sure if this means I need to point LDFLAGS somewhere else, or if this will prevent compiling OpenBLAS for Android.

EDIT confirmed, r23 and up do not include libgcc

@danielcjacobs
Copy link

can you try with the current ndk (23b I believe), just in case this was a temporary regression ?

Tried with r22b and got same error.
Also of note is that the sysroot path for 22b was different from 21e, and 21e also differed from the instructions.

@danielcjacobs
Copy link

danielcjacobs commented Jan 13, 2022

Actually, I am getting a slightly different error with versions before 23b:

/home/djacobs/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld: cannot find crtbegin_so.o: No such file or directory
/home/djacobs/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld: cannot find crtend_so.o: No such file or directory

Here's what I'm running:

export NDK_BUNDLE_DIR=/home/djacobs/Android/Sdk/ndk/21.4.7075529
export PATH=${NDK_BUNDLE_DIR}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin:${NDK_BUNDLE_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
export LDFLAGS="-L${NDK_BUNDLE_DIR}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x -lm"
export CLANG_FLAGS="-target aarch64-linux-android --sysroot ${NDK_BUNDLE_DIR}/sysroot -gcc-toolchain ${NDK_BUNDLE_DIR}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/"

make TARGET=ARMV8 ONLY_CBLAS=1 AR=ar CC="clang ${CLANG_FLAGS}" HOSTCC=gcc -j4

@martin-frbg
Copy link
Collaborator

martin-frbg commented Jan 13, 2022

I have now gotten in to compile with r23b on Fedora34 using just

export PATH=/opt/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
make HOSTCC=gcc CC=/opt/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang ONLY_CBLAS=1 TARGET=ARMV8

can you check if that works for you ? (If you need LAPACK, things will get more complicated due to the current lack of a usable Fortran compiler in the NDK (and in current LLVM in general).

@danielcjacobs
Copy link

Wow, that's very simple and works, thanks! I now see #2005 which probably would've helped me had I looked at the closed issues sooner.

Is ONLY_CBLAS=1 the flag that excludes Fortran? And how is this different from setting NOFORTRAN=1

@martin-frbg
Copy link
Collaborator

martin-frbg commented Jan 13, 2022

ONLY_CBLAS and NOFORTRAN should be identical, just different origins. And the wiki usually carries the collected wisdom from closed tickets, though Android NDK is a bit of a moving target

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

3 participants