[petsc-users] .pc file does not include dependencies

Matthew Knepley knepley at gmail.com
Wed Nov 25 07:07:50 CST 2015


On Wed, Nov 25, 2015 at 6:16 AM, Arne Morten Kvarving <
arne.morten.kvarving at sintef.no> wrote:

> hi,
>
> a while back i was told to use the .pc file for petsc if i wanted
> pkgconfig style (duh) configuration.
> i used to use a (confusingly named) PETScConfig.cmake file for this, which
> was not intended for such use.
>
> problem now is that the pc file of petsc is a bit broken.
>
> in particular, i want to link petsc static, but not all the dependencies.
> if i build petsc (static or not),
> the lib entry is listed as
>
> Libs: -L<path-to-petsc-configuration>/lib  -lpetsc
>
> now, the dependencies are listed in
>
> Libs.private: /usr/lib/liblapack.a /usr/lib/libblas.a libX11.a
> libpthread.a libssl.a libcrypto.a libhwloc.a libm.a
> -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -L/usr/lib/x86_64-linux-gnu
> -L/lib/x86_64-linux-gnu -lgfortran -lm -lgfortran -lm -lquadmath -lm
> -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -L/usr/lib/x86_64-linux-gnu
> -L/lib/x86_64-linux-gnu -lstdc++ -L/usr/lib/gcc/x86_64-linux-gnu/4.9
> -L/usr/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu
> -L/usr/lib/x86_64-linux-gnu -ldl -lgcc_s -ldl -ldl
>
> which are for a totally static link (you'd use --static with pkg-config to
> obtain it).
>
> the problem with a totally static link, however, is that pkg-config
> returns this:
>
> pkg-config --static --libs PETSc ->
>
> /usr/lib/liblapack.a /usr/lib/libblas.a libX11.a libpthread.a libssl.a
> libcrypto.a libhwloc.a libm.a
> -L/home/akva/kode/petsc/current/linux-gnu-cxx-opt/lib
> -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -lpetsc -lgfortran -lquadmath -lm
> -lstdc++ -lgcc_s -ldl
>
> which breaks at linking because petsc won't see any of the symbols in
> those .a files before (static link is order dependent).
>

I do not understand this explanation.

1) Why does the link fail? Please send the error.

2) Is pkgconfig changing/filtering the link line? That would seem like a
bug in pkgconfig.

   Matt


> so i cannot use this file to do a fully static build either (unless i add
> -Wl,--whole-archive or equivalent hacks).
>
> my suggested fix would be to always list the link dependencies in the
> Libs: line (and in the proper order - -lpetsc goes first). this works fine
> with dynamic links (even though -lpetsc would bring in the dependencies)
> and it works with petsc static.
>
> before i try to grok the petsc buildsystem i wanted to check if this would
> be welcome, or even better if i there is something i'm missing..
>
> arnem
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20151125/17ab9123/attachment.html>


More information about the petsc-users mailing list