[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to build one Petsc that works for both C and C++?



This is an MPICH problem. From mpicxx.h:

// There is a name conflict between stdio.h and the MPI C++ binding
// with respect to the names SEEK_SET, SEEK_CUR, and SEEK_END.  MPI
// wants these in the MPI namespace, but stdio.h will #define these
// to integer values.  #undef'ing these can cause obscure problems
// with other include files (such as iostream), so we instead use
// #error to indicate a fatal error.  Users can either #undef
// the names before including mpi.h or include mpi.h *before* stdio.h
// or iostream.

#ifndef MPICH_IGNORE_CXX_SEEK
#ifdef SEEK_SET
#error "SEEK_SET is #defined but must not be for the C++ binding of MPI"
//#undef SEEK_SET
#endif
#ifdef SEEK_CUR
#error "SEEK_CUR is #defined but must not be for the C++ binding of MPI"
//#undef SEEK_CUR
#endif
#ifdef SEEK_END
//#undef SEEK_END
#error "SEEK_END is #defined but must not be for the C++ binding of MPI"
#endif
#endif

I recommend not including stdio.h yourself. PETSc will do it.

  Matt

On 6/17/07, Shi Jin <jinzishuai@xxxxxxxxx> wrote:
But this is what I got trying to compile my C petsc
code with the C++ build:
In file included from
/mnt/200g/works/MyWork/PETSc/C++PETSc/petsc-2.3.3-p3/externalpackages/mpich2-1.0.5p4/linux-gnu-cxx-debug/include/mpi.h:1104,
                 from spAF_incl.h:20,
                 from spAF_analyt.h:11,
                 from spAF_analyt.c:11:
/mnt/200g/works/MyWork/PETSc/C++PETSc/petsc-2.3.3-p3/externalpackages/mpich2-1.0.5p4/linux-gnu-cxx-debug/include/mpicxx.h:26:2:
error: #error "SEEK_SET is #defined but must not be
for the C++ binding of MPI"
/mnt/200g/works/MyWork/PETSc/C++PETSc/petsc-2.3.3-p3/externalpackages/mpich2-1.0.5p4/linux-gnu-cxx-debug/include/mpicxx.h:30:2:
error: #error "SEEK_CUR is #defined but must not be
for the C++ binding of MPI"
/mnt/200g/works/MyWork/PETSc/C++PETSc/petsc-2.3.3-p3/externalpackages/mpich2-1.0.5p4/linux-gnu-cxx-debug/include/mpicxx.h:35:2:
error: #error "SEEK_END is #defined but must not be
for the C++ binding of MPI"
make: *** [spAF_analyt.o] Error 1

Did you do anything special? I am using GCC.
Thanks.

Shi
--- Matthew Knepley <knepley@xxxxxxxxx> wrote:

> On 6/17/07, Shi Jin <jinzishuai@xxxxxxxxx> wrote:
> > Hi,
> >
> > I am learning the unstructured part of Petsc,
> which
> > naturally uses C++(at least the sample I am
> studying
> > is C++). On the other hand, my old Petsc codes are
> all
> > written in C.
> > I found that once I build the Petsc with C++, the
> old
> > C codes cannot be compiled since it is trying to
> use
> > mpicxx to compile the .c source files. However, I
> do
>
> This should be no problem. I do it all the time. Any
> C++
> compiler can compile C just fine.
>
>   Matt
>
> > see after the configuration stage that there is a
> > list:
> > C compiler: mpicc
> > C++ compiler: mpicxx
> > Fortran compiler: mpif77
> >
> > Is it possible to instruct Petsc to use the
> > corresponding  compiler for different source
> codes?
> > Thanks a lot.
> > PS. This is how I configured my Petsc-2.3.3-p3:
> > ./config/configure.py --with-cc=gcc --with-fc=g77
> > --with-cxx=g++ --download-f-blas-lapack=1
> > --download-mpich=1 --with-clanguage=cxx
> --with-sieve=1
> > --download-boost=1 --download-chaco
> > --download-parmetis   --download-fiat
> --download-generator
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Get the Yahoo! toolbar and be alerted to new email
> wherever you're surfing.
> >
>
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
> >
> >
>
>
> --
> What most experimenters take for granted before they
> begin their
> experiments is infinitely more interesting than any
> results to which
> their experiments lead.
> -- Norbert Wiener
>
>



      ___________________________________________________________________________________
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html




--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener