Don't use the -G, or -dn options.
If the dynamic executable being generated has dependencies on any other shared objects, and these dependencies do not reside in /usr/lib, record their pathname in the output file using the -R option (see "Directories Searched by the Runtime Linker").
The following example combines the above points:
$ cc -o prog -R /home/lib -L. -lfoo file1.o file2.o file3.o ..... |