Not 100% clear on this, so anyone who has more experience please feel free
to correct me.
In general, as-needed means that items specified on the command line may
not be linked if they are not needed for any objects preceding them in
the command line.
I believe this is what is happening:
Case 1 (as-needed, failure):
The symbol from -lGL that failed was not needed by anything preceding -lGL
on the command line. Since the as-needed flag is set, g++ just moves on
without linking anything. A later object on the command line
do require the symbol, but by then the -lGL is no longer in play so there
is nothing left to resolve the symbol with.
Case 2 (as-needed, success):
Because -lGL is called _after_ the .o that requires it, the symbols are
correctly linked. When g++ encounters -lGL, it determines that a symbol
is required by one of the preceding objects and links accordingly.
Case 3 (without as-needed):
Without as-needed the default behaviour is to just link everything
that is on the command line, so it does not really matter where on the line
-lGL is specified.
Hope it helps!
devel mailing list