Rust dependency crate not using recognizing linker


Hello. I’m trying to build a rust library for android. The output is a .so file. My project is using the crates regex and typenum. When it goes to build those crates it gives me the error cannot find linker ‘cc’ like this

error: linker cc not found
= note: No such file or directory (os error 2)
error: aborting due to previous error
error: Could not compile typenum.

I am using vagrant to create a clean environment for ubuntu 16.04. I am using Android NDK 16b API 21, for x86.

I use the following commands to create the environment.

curl -sSf | sh
source $HOME/.cargo/env


export ANDROID_NDK_ROOT=$HOME/android-ndk-r16b

python3 $HOME/android-ndk-r16b/build/tools/ --arch x86 --api 21 --install-dir $NDK_TOOLCHAIN_DIR

export PATH=$HOME/x86:$HOME/x86/bin:$PATH

export CC=$NDK_TOOLCHAIN_DIR/bin/i686-linux-android-clang
export AR=$NDK_TOOLCHAIN_DIR/bin/i686-linux-android-ar
export CXX=$NDK_TOOLCHAIN_DIR/bin/i686-linux-android-clang++
export CXXLD=$NDK_TOOLCHAIN_DIR/bin/i686-linux-android-ld
export RANLIB=$NDK_TOOLCHAIN_DIR/bin/i686-linux-android-ranlib
export CROSS_COMPILE=i686-linux-android-
export CFLAGS="-D__ANDROID_API_=21"
export LDFLAGS="-D__ANDROID_API__=21"

cat <<EOF > $HOME/.cargo/config
ar = "${NDK_TOOLCHAIN_DIR}/bin/i686-linux-android-ar"
linker = "${NDK_TOOLCHAIN_DIR}/bin/i686-linux-android-clang"

rustup target add i686-linux-android
cargo build --target=i686-linux-android --release

I have been stuck on this for a while now. Any idea for getting these crates to pick up my settings in the $HOME/.cargo/config file?