[comp.unix.wizards] Unix loader

jeffrey@ccnysci.UUCP (Jeffrey L Bromberger) (02/10/89)

Hi.  I'm using a pretty much Vanilla 4.3 BSD system, and I'm having
problems with loading a file.  Here's what happens:
1) My Fortran program calls a routine in a library
2) The library routine calls another library routine which I want to
	replace.
3) I write my version of this library routine, and get it into 
	the .o format
4) I do a:
	% f77 myprog.f myroutine.o -lstuff
5) The message I get from the fortran compiler is:

   myprog.f:
      MAIN:
   _myroutine_: ld:/usr/local/lib/libstuff.a(myroutine.o): multiply defined

Is there a simple way (in fact, I'd take _any_ way  :-) to have my
routine supercede the one supplied in the library? Am I asking for too
much?  I've got the feeling that there's an option to ld that would do
what I want, but I can't make it out from the man page. Any help would be 
greatly appreciated. 
-- 
Jeffrey L. Bromberger
System Operator---City College of New York---Science Computing Facility
Anywhere!{cmcl2,philabs,phri}!ccnysci!jeffrey	jeffrey@ccnysci.BITNET

steved%mojo@Sun.COM (Steve Dever) (02/10/89)

In article <1247@ccnysci.UUCP> jeffrey@ccnysci.UUCP (Jeffrey L Bromberger) writes:

      [he wants to use his own version of a library routine]
>4) I do a:
>	% f77 myprog.f myroutine.o -lstuff
>5) The message I get from the fortran compiler is:
>
>   myprog.f:
>      MAIN:
>   _myroutine_: ld:/usr/local/lib/libstuff.a(myroutine.o): multiply defined

One thing that might be happening, is the libstuff.a(myroutine.o)
defines one or more symbols that your version does not.  If any
of these symbols are referenced by anything else that is linked in,
the linker will still bring in the version from the library, which causes
the conflict with your routine.  You need to change your version
of myroutine.o so that it contains its own version of all public symbols
in libstuff.a(myroutine.o).

>Jeffrey L. Bromberger
>System Operator---City College of New York---Science Computing Facility
>Anywhere!{cmcl2,philabs,phri}!ccnysci!jeffrey	jeffrey@ccnysci.BITNET


---------------------------
Steve Dever          steved@Sun.COM
                          or
Sun Microsystems     sun!steved

brs@beach.cis.ufl.edu (Ray Seyfarth) (02/10/89)

In article <1247@ccnysci.UUCP> jeffrey@ccnysci.UUCP (Jeffrey L Bromberger) writes:
>1) My Fortran program calls a routine in a library
>2) The library routine calls another library routine which I want to replace.
>...
The answer is that the library is a collection of ".o" files.  It is not a
simple collection of code and data, although each constituent it.  If you
need any data or function from an object file in the library, you get the
whole object file.  For example, assume that "a.o" contains the code for
functions a1 and a2.  If you code your own version of a2 and call function
a1, then you will have 2 versions of a2.  It doesn't matter whether a1 calls
a2 or not.
There is no simple solution.  The solution must depend on your exact needs.
However, I would guess that you need to replace the entire ".o" file being
referenced.  You can use "nm" to determine the contents of your library.
Then you can assess the magnitude of the problem.
--
In Real Life:		UUCP: {gatech|mailrus}!uflorida!beach.cis.ufl.edu!brs
Ray Seyfarth		Internet: brs@beach.cis.ufl.edu
University of Florida	"If you can't look ahead, don't bother to look back."