Partial Static Linkage

Jonathan Wakely
Mon Nov 29 17:23:00 GMT 2010

On 29 November 2010 16:08, Ryan Mansfield wrote:
> On 10-11-29 10:51 AM, Brian McGrew wrote:
>> Good morning all!
>> Is there a way to tell the compiler/linker to use whatever static
>> libraries
>> are available first and then fall back to dynamic libraries only if static
>> fails???
>> I靶e got some libraries that I靶e created that I need to link in and they
>> are static.  However, some of the system libraries I rely on (like libXt)
>> have no static versions.  I need my program to pick up the static versions
>> of my libraries and then link to the dynamic versions of the system
>> libraries that have no static counterparts.
>> Is this doable???  How?
> Use the -Bstatic and -Bdynamic options. e.g.
> -Bstatic <your static libs> -Bdynamic

Or simply don't have shared versions of your libs in the dirs searched
by the linker. If the linker only finds a static lib in a directory it
will use that, even if a shared lib with the same name exists in
another directory later in the list of searched directories.

More information about the Gcc-help mailing list