🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49426

GCC 2.5.8/Solaris 2.2: turning dynamic linking off and on

#49426
From: Irving Reid
Date: Fri, 28 Jan 1994 01:46
32 lines
1939 bytes
We are trying to build a Motif application under Solaris 2.2 using GCC.
Not all of the machines running this application have Motif installed,
so we would like to statically link the Motif libraries while dynamically
linking all the others.

The obvious solution is to use the -Wl option to pass -Bstatic and -Bdynamic
to the linker, like so:

gcc -o foo foo.o -Wl,-Bstatic -lXm -lXt -lX11 ... -Wl,-Bdynamic ...

Unfortunately, the gcc driver collects up all the -Wl arguments and passes
them to the linker together, instead of passing them where they occur on
the command line.  So the linker command looks like:

/usr/ccs/bin/ld ... -Bstatic -Bdynamic -o foo foo.o -lXm -lXt ...

which links everything dynamically.

Other cc drivers (like the HP-UX ANSI C compiler) put each -Wl,... linker
argument in line, rather than collecting them up and putting them all
at the beginning of the ld arguments.

I would rather not have to statically link all the system libraries, both
because of size and because of backward compatibility problems.  I would
also prefer not to write the /usr/ccs/bin/ld command line by hand, because
it has path names of files under gcc-lib which I would have to change
every time we compile with a different version of gcc.

I could just hide the Motif dynamic libraries, but I would prefer to find
a cleaner workaround.

 - irving -
Technical Details
Message-ID: <1994Jan27.204635.21808@jarvis.csri.toronto.edu>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!pipex!uunet!utcsri!sys.toronto.edu!irving

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,a82797485222b85,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1994-01-28 09:50:00 PST
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!pipex!uunet!utcsri!sys.toronto.edu!irving
Newsgroups: gnu.gcc.help
From: irving@sys.toronto.edu (Irving Reid)
Subject: GCC 2.5.8/Solaris 2.2: turning dynamic linking off and on
Message-ID: <1994Jan27.204635.21808@jarvis.csri.toronto.edu>
Organization: CSRI, University of Toronto
Date: 28 Jan 94 01:46:35 GMT
Lines: 32