help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

member functions in several libraries (was Re: questions about link)


From: Kyuso Cahi
Subject: member functions in several libraries (was Re: questions about link)
Date: Sat, 10 Feb 2007 21:17:41 -0800
User-agent: Pan/0.14.2.91 (As She Crawled Across the Table)

Does this mean I can't store member functions of the same class
across several libraries?

I was hoping to avoid polymorphism for delayed implementation of a member
function. Since only one instance of the member function is needed,
polymorphism doesn't seem to be a good solution to this problem.

I would like to interchangeably link different implementation of a member
function stored in different libraries. Is there a better solution?

KC

On Wed, 17 Jan 2007 22:44:29 -0800, Paul Pluzhnikov wrote:
> Chameleon <cham_gss@hotmail.com> writes:
> 
>> So the question is why linker include useless binary objects to final
>> binary executable.
> 
> Because you told it to do so.
> 
> When you link with 
> 
>   g++ main.o foo.o bar.o baz.o -laaa -lbbb -lccc
> 
> then linker is *not allowed* to remove foo.o, bar.o and baz.o from
> the link [1]. Contrast this with:
> 
>   ar ruv libfoobarbaz.a foo.o bar.o baz.o
>   g++ main.o -lfoobarbaz -laaa -lbbb -lccc
> 
> Now the linker can remove foo.o etc. from the link if they are not
> referenced by main.o
> 
> More info here: http://webpages.charter.net/ppluzhnikov/linker.html
> 
> Cheers,
> 
> [1] Some linkers (most notably AIX) ignore what you *explicitly*
> told them to do, and do what they think is "right". Quite often what
> they think is "right" is actually wrong, and tools that think they
> are smarter than the programmer are the first ones to be against
> the wall when the revolution comes.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]