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

android gfortran for windows #1

Closed
zesiha opened this issue May 24, 2016 · 7 comments
Closed

android gfortran for windows #1

zesiha opened this issue May 24, 2016 · 7 comments

Comments

@zesiha
Copy link

zesiha commented May 24, 2016

Hi

I am trying to apply OpenBlas on android app for solving pseudo inverse problem.
Thus, I need 'dgesvd_' function.

However when I was building that function using android NDK, I faced with _Undefined reference to '_gfortran_concat_string' problem.

I found closed issue#460 which is a same problem in linux environment but I realized the fact that I need android toolchains for windows with gfortran to apply '-lgfortran' option in Android.mk .

Unfortunately currently provided android toolchains are only for linux. I was trying to build android gfortran for windows myself based 'https://github.com/buffer51/android-gfortran' but I faced another problem which is relate to 'gmp : Could not find a working compiler'.

Following is a log of building process.

checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=32
checking compiler i386-linux-gnu-gcc -O2 -s -D__USE_MINGW_ANSI_STDIO=1 ... no
configure: error: could not find a working compiler, see config.log for details
Makefile:577: recipe for target 'stmp-config-host-gmp' failed
make[1]: *** [stmp-config-host-gmp] Error 1
make[1]: Leaving directory '/tmp/ndk-cmg/build/toolchain/host-i386-linux-gnu'
Makefile:268: recipe for target 'stmp-build-canadian-tools' failed
make: *** [stmp-build-canadian-tools] Error 2
Error while building mingw/darwin toolchain. See /tmp/ndk-cmg/build/toolchain/config.log
Traceback (most recent call last):
File "./build.py", line 64, in
build_support.run(main, ArgParser)
File "/home/cmg/ndk/build/lib/build_support.py", line 277, in run
main_func(args)
File "./build.py", line 61, in main
build_support.build(build_cmd, args)
File "/home/cmg/ndk/build/lib/build_support.py", line 148, in build
subprocess.check_call(cmd + common_args, env=build_env)
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bash', 'build-gcc.sh', '/home/cmg/toolchain', '/home/cmg/ndk', 'arm-linux-androideabi-4.9', '-j2', '--sysroot=/home/cmg/ndk/platforms/android-9/arch-arm', '--mingw', '--verbose', '--package-dir=/home/cmg/out/dist']' returned non-zero exit status 1

Please anyone help me.
Simply, I just need 'arm-linux-androideabi-gfortran.exe'.

Android Development Environment
OS : WINDOWS 7 64bit
IDE : eclipse
NDK : 11c
Taraget : armv7

gfortran building environment
OS : ubuntu 16.04 64bit (VMware)

Thanks.

@buffer51
Copy link
Owner

Hi,

Just to clarify: you want to build OpenBLAS on Windows, hence you need the gfortran compiler for Android from Windows. But you're trying to build it on Ubuntu using VMware, correct?

First if you're building it on Ubuntu, you'll end up with the gfortran compiler for Android from Linux, which won't run on Windows. I think there's 2 possible solutions:

  • build gfortran on Ubuntu the way you're doing it, then OpenBLAS (still on Ubuntu). After what you'll have both OpenBLAS and the gfortran librairies already built, and you can use them on Windows. If you're having trouble building gfortran yourself, you might consider using the ones I built.
  • try to build gfortran on Windows. I think Android NDK provides some scripts to build the Android toolchain on Windows with MinGW, so you could try to edit those to support FORTRAN as well (similar to what I did for Linux).

Solution 1 seems easier to me. I will see what can be done to build on Windows, I just need to find a Windows machine to try it out.

@zesiha
Copy link
Author

zesiha commented May 25, 2016

Thank you for your answer.
Actually, I don't know how to build gfortran on Windows. (your 2nd solution)

According to the way you did, 'build.py' supports other host using '--host' option.
I tried to build using simple command './build.py --host windows64 --toolchain arm-linux-androideabi'
But it could not proper work.

Plz let me know, what is the problem.

Thanks.

@buffer51
Copy link
Owner

Actually I was wrong, they don't allow building on Windows. What is possible is to build it for Windows from Linux.

I was able to build it for Windows 64-bit. I don't have a Windows so could you try it?
Download it and follow the Deploying steps.

If this works, I'll explain the steps in the README.

@zesiha
Copy link
Author

zesiha commented May 26, 2016

Thank you very much.

The toolchains you gave does work well^^.

Please explain the step in the README.

I also could solve this issue last night.

Following is my solution.

To build android gfortran for windows, two additional step was needed.

  1. gmp : couldn't find a work compiler problem.
    The problem is that there is no reference indicated generated files in /tmp/ndk_$(user)/mingw64_wrapper.

    mkdir ~/prebuilts/gcc/linux-x86/host
    cd /prebuilts/gcc/linux-x86/host
    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8

  2. binutils : Interger overflow.
    binutils-2.25/gold/aarch64.cc file has a bug. Please refer to this article.
    https://sourceware.org/ml/binutils-cvs/2015-07/msg00148.html

    from : // Convert 'adrp' into 'adr'
    Insntype adr_insn = adrp_insn & ((1 << 31) - 1);
    to : // Convert 'adrp' into 'adr'
    Insntype adr_insn = adrp_insn & ((1u << 31) - 1);

Thanks.

@buffer51
Copy link
Owner

I've run into the same problem. It turns out that the script that creates the wrappers assumes you have the MinGW compiler in a specific folder. I changed it to point to the one installed with sudo apt-get install mingw-w64.

I didn't ecounter your second problem. I'll add the steps later this week, if you get a chance to try them and tell me if you still have the binutils problem.

@zesiha
Copy link
Author

zesiha commented May 26, 2016

Hmm,

I did install mingw firstly using 'sudo apt-get install mingw-w64' command.
After that, I did encounter 1st problem.

My system couldn't find prebuilt compilers and so I did install them manually.

Thanks.

@buffer51
Copy link
Owner

I just added the instructions to the README.md. Can you try them to see if you still get your binutils problem?

I'll release prebuilt toolchains for Windows (32-bit & 64-bit) soon.

@buffer51 buffer51 assigned buffer51 and unassigned buffer51 May 31, 2016
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

2 participants