Ahsan Iqbal
Ahsan Iqbal

Reputation: 1432

How to build android standalone toolchain in windows 7

I am trying to build standalone toolchain using ndk 8 for mips by following "docs\STANDALONE-TOOLCHAIN.html" but when I run following command "make-standalone-toolchain.sh --platform=android-14 --install-dir=/tmp/my-android-toolchain" in command prompt I got following errors

E:\Installed_SDKs\android-ndk-r8\build\tools>make-standalone-toolchain.sh --plat
form=android-14 --arch=mips --install-dir=./mytool
Welcome to Git (version 1.7.9-preview20120201)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: name: No such file or directory
./prebuilt-common.sh: line 159: OPTIONS_abstract_Specify: command not found
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: name: No such file or directory
./prebuilt-common.sh: line 159: OPTIONS_abstract_Specify: command not found
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: path: No such file or directory
./prebuilt-common.sh: line 159: path: No such file or directory
./prebuilt-common.sh: line 159: OPTIONS_default_.=: command not found
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: name: No such file or directory
./prebuilt-common.sh: line 159: OPTIONS_abstract_Specify: command not found
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: path: No such file or directory
./prebuilt-common.sh: line 159: path: No such file or directory
./prebuilt-common.sh: line 159: OPTIONS_default_/tmp/ndk-=: No such file or directory
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: path: No such file or directory
./prebuilt-common.sh: eval: line 159: unexpected EOF while looking for matching
`''
./prebuilt-common.sh: eval: line 160: syntax error: unexpected end of file
expr: syntax error
expr: syntax error
./prebuilt-common.sh: line 159: name: No such file or directory
./prebuilt-common.sh: line 159: OPTIONS_abstract_Specify: command not found
./prebuilt-common.sh: line 159: OPTIONS_default_android-3=: command not found
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
ERROR: Unknown option '--platform=android-14'. Use --help for list of valid values.

Can any body guide what I am doing wrong! or how could I build standalone toolchain in windows 7

Regards Ahsan

Upvotes: 3

Views: 4187

Answers (3)

Ntrf
Ntrf

Reputation: 73

Short version:

replace expr -- with expr in file $NDK_HOME/build/tools/prebuilt-common.sh with text editor of your choice. Then run as documented.

Long version:

The syntax errors you see in the output coming from android ndk implementation of argument parser. People who wrote this script decided to use expr command with regular expressions to parse arguments instead of using echo $1 | grep .... It certainly looks much cleaner (even though echo-grep used in other script from ndk), but expr is not the most standart command. It has a set of arguments common to all implementations as detailed in POSIX specification and everything else could be implemented differently or not implemented at all.

If you look inside file $NDK_HOME/build/tools/prebuilt-common.sh at line 392 (could depend on NDK version) you code like this:

param=`expr -- "$1" : '^\([^\-].*\)$'`

Notice how arguments of expr are separated by --. This is not specified in POSIX specification of expr. It's not even mentioned in any Linux man. It just works because some host systems have expr command that recognizes -- as "stop parsing arguments". So this is clearly a case of using an undocumented functionality.

You seem to use Git-bash - version of bash that comes with mingw32-git an distributed by git-scm.org. This version does not support expr -- syntax to the whole argument parsing library breaks. In order to fix it - just replace all expr -- with expr in prebuilt-common.sh file. It will still throw some warnings at you, but the script should work.

Upvotes: 2

Akshay Mukadam
Akshay Mukadam

Reputation: 2438

When it comes to cross compilation of library which are written in C we require NDK. But Compiling such type of Library on windows is very difficult and sometimes stuck and its always frustrating. I advise you to try the compilation on Linux. It will definitely be compiled. Linux/Mac are the best platforms for cross compilation. I hope it should help

Upvotes: 1

Alex Cohn
Alex Cohn

Reputation: 57203

$ E:>Installed_SDKs/android-ndk-r9d/build/tools/make-standalone-toolchain.sh --platform=android-14 --arch=mips --system=windows-x86_64

generates /tmp/ndk-/mipsel-linux-android-4.6.tar.bz2 for me; now I can unpack this file to E:\Installed_SDKs\android-ndk-r8\build\tools\mytool and live happily ever after.

Upvotes: 4

Related Questions