Linker incorrectly resolving all symbols, not just ones used.

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

 



The way I understand it, when you link against libraries, the linker pulls
in only the objects you need to resolve the symbols in your program.  A
couple of fellow programmers working on the project with me mentioned to
me that for some reason they have to link with all of our libraries,
regardless or not if we are using that part.  So I did some investigation
and it seems something is wrong.

Here at work we have various libraries that include standard classes that
we can use, all written in C++.  And they are built using gcc, and
archived using "gcc -static ".  And the final program is actually linked
with "g++ -static"  This is on linux using gcc 3.2.

Here is how I verified this problem.  In a program that creates an object
of type tcA, there is also a class tcB in the same library.  I commented
out a method body that is defined in class tcB, and is only called from
within tcB's constructor.  When I do the final linking of the test
program, it complains about this unresolved reference, but since I don't
create an objecct of type tcB, this should not matter right?

So my questions are, what is the correct behavior?  If not correct is it
flag problem, or design problem.
Thanks,
Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux