Perhaps the easy fix is to build PETSc as shared libraries. [this is the 
default anyway]

However wrt pkgconfig:

>>>>
$ cat arch-linux-c-debug/lib/pkgconfig/petsc.pc 
prefix=/home/balay/petsc/arch-linux-c-debug
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib
ccompiler=mpicc
cflags_extra=-fPIC -Wall -Wwrite-strings -Wno-unknown-pragmas 
-Wno-stringop-overflow -fstack-protector -fvisibility=hidden -g3 -O0
cflags_dep=-MMD -MP
ldflag_rpath=-Wl,-rpath,
cxxcompiler=mpicxx
cxxflags_extra=-Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas 
-fstack-protector -fvisibility=hidden -g -O0  -std=gnu++17 -fPIC
fcompiler=mpif90
fflags_extra=-fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g -O0

Name: PETSc
Description: Library to solve ODEs and algebraic equations
Version: 3.16.99
Cflags:   -I${includedir} -I/home/balay/petsc/include
Libs: -L${libdir} -lpetsc
Libs.private: -L/home/balay/soft/mpich-3.4.2/lib 
-L/usr/lib/gcc/x86_64-redhat-linux/11 -llapack -lblas -lm -lX11 -lstdc++ -ldl 
-lmpifort -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -ldl
<<<<

i.e 'Libs' provides the petsc library [usable when built as shared] - and 
'Libs.private' provides all the dependencies [that are required in a static 
build]

Satish



On Tue, 22 Feb 2022, Palmer, Bruce J via petsc-users wrote:

> Hi,
> 
> We recently switched the CMake configuration on our GridPACK application to 
> use the PkgConfig utility instead of Jeb Brown’s FindPETSc.cmake module. This 
> seems to work on a number of platforms but it is failing to link on others. 
> It appears that the build cannot find the LAPACK and BLAS libraries. The 
> PETSc library I’m linking to (v3.16.3) was configured with 
> -download-f2cblaslapack so it should have these libraries, but when I try and 
> link one of the test applications in GridPACK I get the errors
> 
> 
> /share/apps/gcc/6.1.0/bin/g++ -pthread -g -rdynamic 
> CMakeFiles/greetings.dir/test/greetings.cpp.o -o greetings  
> -Wl,-rpath,/qfs/projects/ops/rh6/openmpi/3.0.1/gcc/6.1.0/lib 
> ../math/libgridpack_math.a libgridpack_parallel.a 
> ../timer/libgridpack_timer.a ../environment/libgridpack_environment.a 
> ../math/libgridpack_math.a 
> /pic/projects/gridpack/software/boost_1_65_0/lib/libboost_mpi.a 
> /pic/projects/gridpack/software/boost_1_65_0/lib/libboost_serialization.a 
> /pic/projects/gridpack/software/boost_1_65_0/lib/libboost_random.a 
> /pic/projects/gridpack/software/boost_1_65_0/lib/libboost_filesystem.a 
> /pic/projects/gridpack/software/boost_1_65_0/lib/libboost_system.a 
> /pic/projects/gridpack/software/ga-5.7/build_pr/lib/libga++.a 
> /pic/projects/gridpack/software/ga-5.7/build_pr/lib/libga.a 
> /pic/projects/gridpack/software/ga-5.7/build_pr/lib/libarmci.a -lrt 
> /usr/lib64/librt.so /usr/lib64/libdl.so 
> /qfs/projects/ops/rh6/openmpi/3.0.1/gcc/6.1.0/lib/libmpi.so 
> ../timer/libgridpack_timer.a libgri
 dpack_pa
 rallel.a ../configuration/libgridpack_configuration.a 
/pic/projects/gridpack/software/petsc-3.16.3/linux-openmpi-gnu-cxx-complex-opt/lib/libpetsc.a
> 
> /pic/projects/gridpack/software/petsc-3.16.3/linux-openmpi-gnu-cxx-complex-opt/lib/libpetsc.a(zstart.o):
>  In function `petscinitializef_':
> 
> /pic/projects/gridpack/software/petsc-3.16.3/src/sys/objects/ftn-custom/zstart.c:280:
>  undefined reference to `mpi_init_'
> 
> /pic/projects/gridpack/software/petsc-3.16.3/linux-openmpi-gnu-cxx-complex-opt/lib/libpetsc.a(baijfact.o):
>  In function `MatSolve_SeqBAIJ_N':
> 
> /pic/projects/gridpack/software/petsc-3.16.3/src/mat/impls/baij/seq/baijfact.c:1462:
>  undefined reference to `zgemv_'
> 
> /pic/projects/gridpack/software/petsc-3.16.3/src/mat/impls/baij/seq/baijfact.c:1475:
>  undefined reference to `zgemv_'
> 
> /pic/projects/gridpack/software/petsc-3.16.3/src/mat/impls/baij/seq/baijfact.c:1478:
>  undefined reference to `zgemv_'
> 
> /pic/projects/gridpack/software/petsc-3.16.3/linux-openmpi-gnu-cxx-complex-opt/lib/libpetsc.a(baijfact.o):
>  In function `MatSolve_SeqBAIJ_N_NaturalOrdering':
> 
> /pic/projects/gridpack/software/petsc-3.16.3/src/mat/impls/baij/seq/baijfact.c:1407:
>  undefined reference to `zgemv_'
> 
> /pic/projects/gridpack/software/petsc-3.16.3/src/mat/impls/baij/seq/baijfact.c:1420:
>  undefined reference to `zgemv_'
> 
> /pic/projects/gridpack/software/petsc-3.16.3/linux-openmpi-gnu-cxx-complex-opt/lib/libpetsc.a(baijfact.o):/pic/projects/gridpack/software/petsc-3.16.3/sr
> 
> I suspect that the reason it worked for others and not for me is that they 
> had viable blas and lapack libraries in their path and I don’t. Is there 
> anything special you need to do to make sure that the build is pointed at the 
> libraries that get created with the -download-f2cblaslapack option?
> 
> Bruce Palmer
> 

Reply via email to