Re: Relink against a single library
From: Gary R. Hook (nospam_at_nospammers.net)
Date: 07/29/03
- Next message: Gary R. Hook: "Re: Newbie: Patch Updates"
- Previous message: BBCONS GmbH: "cron does no restart"
- In reply to: Thorsten Westheider: "Relink against a single library"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Jul 2003 15:39:26 GMT
Thorsten Westheider wrote:
> Suppose I have an executable foo that was linked against lib1.a,
> lib2.a and lib3.a at some time in the past. Now there has been a
> change in, say, lib2.a (but not in either lib1.a or lib3.a) requiring
> to relink foo. Question: Is there a way to link against lib2.a only?
On AIX, yes. Not on other platforms. On AIX, all modules
produced by the linker can be used as input to the linker.
> You may ask 'Why would anybody want to do that?'
Actually, it's not an uncommon question, and quite reasonable.
You'll need the interface for the app, if it exports any
symbols (dump -HTv), and the libpath in the executable.
The rtl_enable -s script might prove useful for this purpose.
Anyway, you can replace object code by listing new .o files
first on the command line, then list the executable. If you
have an archive, you'll need to either extract archive
members of interest (ar -xv lib2.a foo.o) or pre-link it into
a single .o file (ld -r -o tmp.o lib2.a). Then:
ld -o new-exec-file tmp.o old-exec-file -bE:<exports> -lpthread \
-lc ... -blibpath:<libpathfromexecutable>
Again, rtl_enable shows this technique, so use the -s option
to generate the scripts and study them.
-- Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE ________________________________________________________________________
- Next message: Gary R. Hook: "Re: Newbie: Patch Updates"
- Previous message: BBCONS GmbH: "cron does no restart"
- In reply to: Thorsten Westheider: "Relink against a single library"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]