Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to use prebuilt binaries to compile Android from source. The problem is, that seems like it's using the binaries I do not want it to use. As far as I understand gcc from the first directory in PATH that contains gcc will be used. But it's not.

This is my script for overriding PATH

#!/bin/bash

# The directory from which I want to use gcc, c++ etc
export PATH=/run/media/doctor/temporary/C811_Build_ICS/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/arm-eabi/bin

# Other stuff that I need
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/bin:
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/build-tools/19.0.0/
export PATH=$PATH:/opt/java6/bin:/opt/java6/db/bin
export PATH=$PATH:/opt/java6/jre/bin
export PATH=$PATH:/opt/android-ndk

These are the contents of the toolchain directory

$ ls -1 /run/media/doctor/temporary/C811_Build_ICS/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/arm-eabi/bin
ar
as
c++
g++
gcc
ld
nm
objcopy
objdump
ranlib
strip

Now I run

$ ./toolchain.sh 
$ which gcc
/usr/bin/gcc

And get the gcc that I don't want.

share|improve this question
1  
You need to use source ./toolchain.sh or (equivalent . ./toolchain.sh). Otherwise a new bash instance is spawned (where the variables are set), but this instance exists immediately... hence you lose the new settings. –  mpy Nov 17 '13 at 10:53

1 Answer 1

up vote 2 down vote accepted

export command exports variables to new processes created from your current shell, but it does not export them to "parent" processes / shells.

You can take a look to these threads for more information:

You should source your file (it does not have to be an executable file), instead of running it:

$ source toolchain
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.