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

Satish Balay balay at mcs.anl.gov
Wed Nov 25 12:53:47 CST 2015


I don't see this behavior on my  linux box.

i.e [with --static option] -lpetsc is listed before -lx11

Satish

balay at asterix /home/balay/petsc/arch-maint/lib/pkgconfig (maint>)
$ cat PETSc.pc 
prefix=/home/balay/petsc
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=/home/balay/petsc/arch-maint/lib
ccompiler=mpicc
fcompiler=mpif90
blaslapacklibs=-llapack -lblas

Name: PETSc
Description: Library to solve ODEs and algebraic equations
Version: 3.6.2
Cflags: -I/home/balay/petsc/include -I/home/balay/petsc/arch-maint/include -I/home/balay/soft/mpich-3.1.4/include
Libs: -L/home/balay/petsc/arch-maint/lib  -lpetsc
Libs.private: liblapack.a libblas.a libX11.a libpthread.a libm.a -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -L/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lmpifort -lgfortran -lm -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lgfortran -lm -lquadmath -lm -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -L/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lmpicxx -lstdc++ -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -L/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -ldl -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -lmpi -lgcc_s -ldl balay at asterix /home/balay/petsc/arch-maint/lib/pkgconfig (maint>)
$ pkg-config --libs PETSc
-L/home/balay/petsc/arch-maint/lib -lpetsc 
balay at asterix /home/balay/petsc/arch-maint/lib/pkgconfig (maint>)
$ pkg-config --static --libs PETSc
-L/home/balay/petsc/arch-maint/lib -L/home/balay/soft/mpich-3.1.4/lib -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -L/home/balay/soft/mpich-3.1.4/lib -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -L/home/balay/soft/mpich-3.1.4/lib -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lpetsc liblapack.a libblas.a libX11.a libpthread.a libm.a -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lmpifort -lgfortran -lm -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lgfortran -lm -lquadmath -lm -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -lmpicxx -lstdc++ -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/5.1.1 -ldl -Wl,-rpath,/home/balay/soft/mpich-3.1.4/lib -lmpi -lgcc_s -ldl 
balay at asterix /home/balay/petsc/arch-maint/lib/pkgconfig (maint>)
$ pkg-config --version
0.28
balay at asterix /home/balay/petsc/arch-maint/lib/pkgconfig (maint>)
$ 

On Wed, 25 Nov 2015, Arne Morten Kvarving 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).
> 
> 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