问题
I noticed that when I make my application with gcc and look at the output during the linking phase, I see the following lib included twice:
/home/rb01/opt/trx-HEAD/gcc/4.2.4/lib/../lib64/libstdc++.so
And so I was just wondering if this is a problem with g++ (gcc) or if the second one is simply ignored?
Thanks!
回答1:
If symbols in a library have already been resolved, the linker ignores them. With shared libraries, as in this case, the linker doesn't actually link anyway.
With static (.a) libraries, multiple copies on the command line can actually be useful, if not very pretty, if for example main accesses libb which accesses libc which accesses something in libb not accessed by main:
ld main.o -lb -lc -lb
is one way to get all the references resolved.
来源:https://stackoverflow.com/questions/2282486/can-linking-with-the-same-library-twice-be-a-problem-with-g