[petsc-dev] Problem with petsc.pc when configured with --with-single-library=0

Jed Brown jed at jedbrown.org
Wed Mar 1 10:22:23 CST 2017


Barry and Garth, should we include RPATH flags in the Libs field of
PETSc.pc?  We normally include them in makefiles because PETSc is often
installed to places that aren't in the search path and environment
variables (LD_LIBRARY_PATH) are evil.

Are you aware of any conventions for handling RPATH in pkg-config?
There is --libs-only-l, --libs-only-L, and --libs-only-other so someone
could filter out the rpath flags by using only the first two.

I put this in a Makefile:

PETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc

CC := $(shell pkg-config --variable=ccompiler $(PETSc.pc))
CPPFLAGS := $(shell pkg-config --cflags-only-I $(PETSc.pc))
CFLAGS := $(shell pkg-config --cflags-only-other $(PETSc.pc))
LDFLAGS := $(shell pkg-config --libs-only-L --libs-only-other $(PETSc.pc))
LDLIBS := $(shell pkg-config --libs-only-l $(PETSc.pc)) -lm


With no other targets (i.e., using only built-in rules), I can build
examples in the current directory.  E.g.,

$ make ex5
mpicc  -I/home/jed/petsc/include -I/home/jed/petsc/ompi-opt/include -L/home/jed/petsc/ompi-opt/lib  ex5.c  -lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsys -lm -o ex5

Should we add variables for coptflags?

I feel like we should try to make the above a recommended way to build,
as an alternative to including the makefiles that have zillions of
undocumented non-namespaced variables.  Note that when using PETSc
together with other packages, the above is trivial to extend and doesn't
risk namespace collision.

Jed Brown <jed at jedbrown.org> writes:

> Garth, I put a fix in 'next'.  Dolfin configures for me now.
>
> Barry, the fact that PETSc.pc has been broken for four years is why
> someone might use FindPETSc.cmake.  (Garth changed their CMake to use
> pkg-config instead of the uglier logic, but then it fails with no
> debugging output.)
>
> "Garth N. Wells" <gnw20 at cam.ac.uk> writes:
>
>> When configuring PETSc with "--with-single-library=0", my installed 
>> petsc.pc file looks like:
>>
>> prefix=/home/garth/local/packages/petsc-test
>> exec_prefix=${prefix}
>> includedir=${prefix}/include
>> libdir=/home/garth/local/packages/petsc-test/lib
>> ccompiler=mpicc
>> fcompiler=mpif90
>> blaslapacklibs=-llapack -lblas
>>
>> Name: PETSc
>> Description: Library to solve ODEs and algebraic equations
>> Version: 3.7.5
>> Cflags: -I/home/garth/local/packages/petsc-test/include 
>> -I/home/garth/local/packages/petsc-test/include
>> Libs: -L/home/garth/local/packages/petsc-test/lib  -lpetsc
>> Libs.private: -llapack -lblas -lX11 -lpthread -lm 
>> -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu 
>> -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/6 
>> -L/usr/lib/gcc/x86_64-linux-gnu/6 -Wl,-rpath,/lib/x86_64-linux-gnu 
>> -L/lib/x86_64-linux-gnu -lmpichfort -lgfortran -lm -lgfortran -lm 
>> -lquadmath -lm -lmpichcxx -lstdc++ -Wl,-rpath,/usr/lib/x86_64-linux-gnu 
>> -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/6 
>> -L/usr/lib/gcc/x86_64-linux-gnu/6 -Wl,-rpath,/usr/lib/x86_64-linux-gnu 
>> -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/lib/x86_64-linux-gnu 
>> -L/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu 
>> -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lgcc_s -ldl
>>
>>
>> Note the "Libs:". It points only to petsc (which doesn't exist), 
>> whereas I would expect it to list each PETSc lib, i.e., petscdm, 
>> petscksp, etc, or provide a pkg-config file for each PETSc lib.
>>
>> Garth
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20170301/c374b304/attachment.sig>


More information about the petsc-dev mailing list