ML symbols in petscksp.so

Jed Brown jed at 59A2.org
Thu Oct 29 13:45:11 CDT 2009


Jed Brown wrote:
> Jed Brown wrote:
>> Satish Balay wrote:
>>> I don't see any changes in the 'shared' target for linux [in conf/rules]
>>>
>>> And I just did a build with current petsc-dev - and see a bunch of ML_ symbols
>> Thanks Satish.  Wiping externalpackages and PETSC_ARCH was enough.
> 
> I spoke too soon.

Okay, my problem was that a completely different package (OpenCV, a
dependency for something else) installed a libml in /usr/lib, the timing
was just coincidental.  Since I keep some libraries in /usr (like
parmetis and hdf5), -L/usr/lib came before -L${PETSC_LIB_DIR} in
PACKAGES_LIBS, therefore the wrong libml was linked in shared_linux.
OTOH, the correct one was linked for the examples because
-L${PETSC_LIB_DIR} was prepended to the link line.  The complete story
follows, in case someone else runs into this issue.


So I had

/usr/lib/libml.so (opencv)
$PETSC_DIR/$PETSC_ARCH/lib/libml.a ($PETSC_LIB_DIR/libml.a)

The link for shared_arch is effectively

  -L/usr/lib -L${PETSC_LIB_DIR} -lml

which brings in /usr/lib/libml.so which doesn't resolve anything, but
the linker doesn't complain about unresolved symbols because it was
building a shared library.  Now we might expect an example to actually
fail over this, but that is linked with

  -L{PETSC_LIB_DIR} -lpetsc* ${PETSC_EXTERNAL_LIB_BASIC}

so this time it is resolved to the correct $PETSC_LIB_DIR/libml.a.


I realize that the real problem here was OpenCV's libml and the fact
that linkers don't resolve symbols by starting with the most recent -L
path [*], but we should at least remember that putting -L{PETSC_LIB_DIR}
at the beginning of the line can completely change the way symbols are
resolved.


Jed


[*] I find PETSc link lines to be slightly deceptive.  They often look
like

  -L/A -rpath=/A -lA -L/B -rpath=/B -lB

with the implication that it would resolve to /A/libA.a /B/libB.a, but
the linker will find /A/libB.a if it exists.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20091029/a899b7e8/attachment.sig>


More information about the petsc-dev mailing list