On 08/20/2012 05:53 AM, Tayade, Nilesh wrote: > I have a basic query related to linking of static and dynamic libraries. > > My program needs to use 'libcrypto', libssl and libnetsnmp libraries. > Out of these, the libnetsnmp and libssl have dependency on libcrypto. > For some reason, I need to link the libcrypto and libssl statically to my program. > So I have built libcrypto.a and libssl.a and I am able to link them correctly. > > But when libnetsnmp gets linked, since it is a shared object, it also links libcrypto.so. > So why should libnetsnmp again try to link libcrypto.so when the symbols are already resolved while statically linking libcrypto.a? Because libnetsnmp has a run-time dependency on libcrypto, not a compile- time dependency. > Is there some way to avoid it? I tried using -static and -Bstatic. It's going to be very difficult. C has a "One Definition Rule" which says that in any running program there must only be one definition of each symbol. Clearly, what you're trying to do will violate that rule. I would seriously try to find a way to link your program against libcrypto.so. Andrew.