Ubuntu – Symbolic link doesn’t use target working directory

symbolic-link

I've created the following symbolic link:

Source: /usr/local/android-ndk-r5/ndk-build
Destination: /usr/local/bin/ndk-build

However, when I attempt to use ndk-build from my source directory, it fails because it can't find files that the script depends on in the source directory.

How can I get the symbolic link to use the source directory as the working directory?

Best Answer

You can't, you need to make a wrapper script.

Assuming that the program relies on the filename for determining the script (likely):

#!/bin/sh
exec /usr/local/android-ndk-r5/ndk-build "$@"

Assuming that the program relies on the current working directory (unlikely):

#!/bin/sh
cd /usr/local/android-ndk-r5
exec ./ndk-build "$@"

Save one of these files in /usr/local/bin/ndk-build and make it executable:

sudo editor /usr/local/bin/ndk-build
sudo chmod 755 /usr/local/bin/ndk-build
Related Question