# Compile Programs (bash) from source for Android



## tutysara (Jul 9, 2011)

Hi,
I am trying to compile bash from source on android.
I am using the pre-built tool chain that comes with android for cross-compiling.
I am using this command


```
export CC=/home/tutysra/src/aosp/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc<br />
./configure -build=arm-unknown-eabi -host=arm-unknown-linux-gnu -enable-static-link -without-bash-malloc
```
It is getting struck with an error message


```
[email protected]:~/src/bash-4.0$ ./configure -build=arm-unknown-eabi -host=arm-unknown-linux-gnu -enable-static-link -without-bash-malloc<br />
checking build system type... arm-unknown-eabi<br />
checking host system type... arm-unknown-linux-gnu<br />
checking for emacs... no<br />
checking for xemacs... no<br />
<br />
Beginning configuration for bash-4.0-release for arm-unknown-linux-gnu<br />
<br />
checking for arm-unknown-linux-gnu-gcc... /home/tutysra/src/aosp/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc<br />
checking for C compiler default output file name... <br />
configure: error: in `/home/tutysra/src/bash-4.0':<br />
configure: error: C compiler cannot create executables<br />
See `config.log' for more details.<br />
[email protected]:~/src/bash-4.0$
```
Has anyone did something similar and got the executable for android from source?


----------



## r2doesinc (Jun 8, 2011)

idk what your source is, but heres what we use in OMFGB. https://github.com/OMFGB/external_bash


----------



## tutysara (Jul 9, 2011)

r2doesinc said:


> idk what your source is, but heres what we use in OMFGB. https://github.com/OMFGB/external_bash


I am using the source from - ftp://ftp.cwru.edu/pub/bash/bash-4.0.tar.gz.
Then using the android pre-built arm-eabi compiler to build it.

BTW what compiler do you use?


----------



## tutysara (Jul 9, 2011)

./Configure was successful after installing the compiler from codesourcery.
Not sure why it is failing with the pre-build cross compiler that comes with android source.
It had failed at a later stage when compiling some file.

I got your source from github.
I found a Andriod.mk file in the So, tried compiling with ndk-build.
However I am getting the following exception


```
[email protected]:~/src/github/temp$ ndk-build<br />
Compile thumb  : sh <= shmatch.c<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:36:19: error: regex.h: No such file or directory<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c: In function 'sh_regmatch':<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:50: error: 'regex_t' undeclared (first use in this function)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:50: error: (Each undeclared identifier is reported only once<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:50: error: for each function it appears in.)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:50: error: expected ';' before 'regex'<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:51: error: 'regmatch_t' undeclared (first use in this function)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:51: error: 'matches' undeclared (first use in this function)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:66: error: 'REG_EXTENDED' undeclared (first use in this function)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:68: error: 'REG_ICASE' undeclared (first use in this function)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:73: error: 'regex' undeclared (first use in this function)<br />
/home/tutysra/src/github/temp/jni/lib/sh/shmatch.c:77: error: expected expression before ')' token
```
Does this code compile for you? What compilation method are you using?


----------

