How to link executable without indirectly-referenced libraries?

I am wondering if anyone can help me with this. I wrote a dynamic shared library (called, which references functions defined in another dynamic shared library (called Now, I created an executable that references the functions defined in, but not those defined in However, as I try to link the executable with, the linker (gcc) complains that symbols referenced in are undefined. It means I am forced to link the executable with both and

For various internal reasons, I need to avoid this situation. The executable should only be linked with Since both libraries are in the paths included in LD_LIBRARY_PATH, running the executable should cause no problem as long as finding the necessary libraries at runtime is concerned.

Could anyone help? The exact same method (i.e. only linking with works perfectly fine on both Linux (RHEL 4/5) and Solaris 9/10, just not FreeBSD (6.2).