Two ways this can be achieved
a) Setting rpath
at linktime - this is a very ugly and unportable way and should be avoided whereever possible
b) Using the LD_LIBRARY_PATH
environment variable (don't forget to export that if you change it!)
If you want to use a specific version/modified/foo-reason for your binary I suggest to
a) link against it statically if the license allows that
b) use LD_PRELOAD
like explained here https://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick
c) modify the LD_LIBRARY_PATH
(make sure your path is the very first in that list, they are searched in order) by using a run-script which does that