I apologize if this has been asked before; I searched the forum and didn't find anything.

Is it possible to compile and link a program using GCC such that some of the libraries are linked in as static libraries while the rest are shared?

For example, I have a program, foo, that uses the socket and nsl libraries, but also uses a custom library that won't be available on all systems. I want to link libsocket and libnsl as shared libraries, but the custom one as static.

Can this be done? If so, what is the command line option in GCC for doing so? Thanks in advance.