[petsc-dev] petsc/master: unable to link in C++ with last night PETSC_WITH_EXTERNAL_LIB variable changes

Jed Brown jed at jedbrown.org
Mon Feb 12 11:11:14 CST 2018


Eric Chamberland <Eric.Chamberland at giref.ulaval.ca> writes:

> Hi again Jed,
>
> sorry to bother you again: if you prefer I can go back on the petsc-dev 
> list, as you wish.

Better to stay on list.

> Here is my new question:
>
> Is this a small inconsistency?  Or is it related to the way I configured 
> petsc? (see 
> http://www.giref.ulaval.ca/~cmpgiref/petsc-master-debug/2018.02.12.02h00m01s_configure.log)
>
> pkg-config --cflags-only-I PETSc
> -I/opt/petsc-master_debug/include 
> -I/opt/intel/composer_xe_2015.2.164/mkl/include 
> -I/opt/openmpi-1.10.2/include
>
> pkg-config --libs PETSc
> -L/opt/petsc-master_debug/lib -lpetsc
>
> why does mpi stuff appears in the first one and not the second?
>
> I would prefer to have "-lmpi" in the second one too... When is it 
> decided to "hide" external packages "under" PETSc? At configuration time?

I don't know what pkg-config recommends in this situation, but consider
that petscsys.h includes mpi.h so a corresponding -I flag needs to be on
the command line any time you compile code that calls PETSc.  If your
application never calls MPI directly, it would be safe to link without
-lmpi.

Also note that PETSc provides symbols (like PETSC_COMM_WORLD) which also
have the effect that merely calling PETSc does not require directly
referencing MPI symbols (MPI_COMM_WORLD is a symbol, not a macro, in
Open MPI).

And that PETSc built with MPICH can be linked unmodified with other
conforming MPI implementations.

  http://www.mpich.org/abi/


More information about the petsc-dev mailing list