Either set your LD_LIBRARY_PATH
environment variable to contain /usr/local/lib
or add /usr/local/lib
to /etc/ld.so.conf
and run ldconfig
as root.
Also, run ldd a.out
to check that dynamic linking works well on your app.
Read ld-linux(8), ldconfig(8), ldd(1)