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

Jed Brown jed at jedbrown.org
Sat Feb 10 15:48:36 CST 2018


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

> ok, let put our in-house code away, simply try this simple example:
>
> ----------
>
> #include <mpi.h>
>
> int main() {
> /*empty!! let's see the .o */
>
> return 1;
>
> }
> ---------
>
> then:
>
> g++ -c test.cc -I/opt/openmpi-1.10.2/include -o test.o
>
> nm -C test.o | grep "MPI::" | grep " U "
>
>                   U MPI::Win::Free()
>                   U MPI::Comm::Comm()
>                   U MPI::Datatype::Free()
>
> so: as soon you are compiling a c++ file with this openmpi 1.10.2 (even 
> if you use gcc -c test.cc -I/opt/openmpi-1.10.2/include -o test.o in my 
> example) it *requires* you to link with mpi_cxx lib...

That's sad, but is this not avoided by defining OMPI_SKIP_MPICXX before
including mpi.h?  (There is also MPICH_SKIP_MPICXX if you want.)  This
is done by default in petscsys.h, but you might not include it in that
file or don't include it before mpi.h is included.


More information about the petsc-dev mailing list