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

Arne Morten Kvarving arne.morten.kvarving at sintef.no
Wed Nov 25 06:16:01 CST 2015


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).

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


More information about the petsc-users mailing list