[petsc-users] Linking error with C++ code: undefined symbols

Satish Balay balay at mcs.anl.gov
Tue Mar 23 20:12:05 CDT 2010


For one we recommend using the latest version i.e petsc-3.0.0 [or the
upcoming petsc-3.1 - via petsc-dev] - but not this old version 2.3.3.

Secondly - if you want to use PETSc from c++ - the recommended way is
to build it with the configure option '--with-clanguage=cxx'

And then [after making sure the examples work] use "petsc.h" without
the "extern C" etc. in your code.

If the examples compile fine - - but not your code - the issuse is
usually the makefile [make it as close to a petsc makefile as possible
- for eg: src/ksp/ksp/examples/tutorials/makefile].

Satish

On Tue, 23 Mar 2010, charles reid wrote:

> (Please let me know if I can give any additional information that would be
> helpful for this problem.)
> 
> 
> I'm trying to use Petsc in an object-oriented C++ code, developing with g++
> on Mac OS X 10.5, and I'm running into some problems in the linking stage.
> I've defined an object that uses Petsc (what I'm calling the GmresSolver
> class), and the object compiles just fine.  However, when it comes time to
> compile the driver (Laplace.cc) and link to Petsc libraries, I see a bunch
> of "Undefined symbol" errors.
> 
> In my object code that uses Petsc (GmresSolver.h), I have included the Petsc
> header file as:
> extern "C" {
> #include "petscksp.h"
> }
> 
> In the driver (Laplace.cc), depending on how I include the Petsc header
> file, I get different errors.  If I include it like I do in GmresSolver.h,
> extern "C" {
> #include "petsc.h"
> }
> 
> I get a whole slew of header file syntax errors (see postscript of email).
> If I just include the header file,
> #include "petsc.h"
> 
> then I get the undefined symbols problem (more below).
> 
> 
> My configure line for Petsc is
> Users/charles/pkg/petsc-2.3.3-p15/config/configure.py \
>    --prefix=$HOME/pkg/petsc-2.3.3-p15 \
>    --with-python \
>    --with-mpi=0 \
>    --with-debugging=1 \
>    PETSC_DIR=$HOME/pkg/petsc-2.3.3-p15
> 
> 
> 
> Here's my step-by-step to produce the error:
> 
> 1. Compile all non-Petsc object code
> 
> 2. Compile object code that uses Petsc using this command:
> 
> g++ -c -Wall  -I.  -I/Users/charles/pkg/petsc-2.3.3-p15
> -I/Users/charles/pkg/petsc-2.3.3-p15/bmake/darwin9.5.0-c-opt
> -I/Users/charles/pkg/petsc-2.3.3-p15/include ./GmresSolver.
> 
> (as mentioned, this works fine.)
> 
> 3. Compile the driver, "Laplace.cc", and link it to Petsc's libraries:
> 
> g++  \
>  -I/Users/charles/pkg/petsc-2.3.3-p15/  \
>  -I/Users/charles/pkg/petsc-2.3.3-p15/include  \
>  -I/Users/charles/pkg/petsc-2.3.3-p15/include/mpiuni  \
>  -I/Users/charles/pkg/petsc-2.3.3-p15/include/petsc \
>  -DPETSC_STATIC_INLINE=""  \
>  Laplace.cc  \
>  -L/Users/charles/pkg/petsc-2.3.3-p15 \
>  -L/Users/charles/pkg/petsc-2.3.3-p15/lib/darwin9.5.0-c-opt \
>  -lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc \
>  BoundaryConditionFactory.o  BoundaryCondition.o Field.o FileIO.o
> GmresSolver.o JacobiSolver.o Timer.o TimerFactory.o
> 
> (Note: I don't know why I need -DPETSC_STATIC_INLINE="", but I do, otherwise
> I see a bunch of errors like "petsc-2.3.3-p15/include/petscviewer.h:117:
> error: ‘PETSC_STATIC_INLINE’ does not name a type" - anyone know what that's
> all about?)
> 
> This last compiler command gives the undefined symbols errors:
> 
> Undefined symbols:
>   "PetscOptionsGetReal(char const*, char const*, double*, PetscTruth*)",
> referenced from:
>       PetscOptionsGetReal(char const*, double*, PetscTruth*)in ccPG7mg3.o
>   "_Petsc_MPI_Abort", referenced from:
>       _PetscMaxSum_Local in libpetsc.a(pinit.o)
>       _PetscADMax_Local in libpetsc.a(pinit.o)
>       _PetscADMin_Local in libpetsc.a(pinit.o)
>       _PetscSynchronizedFlush in libpetsc.a(mprint.o)
>       _PetscSynchronizedFlush in libpetsc.a(mprint.o)
>       _PetscOptionsCheckInitial_Private in libpetsc.a(init.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscError in libpetsc.a(err.o)
>       _PetscMallocDumpLog in libpetsc.a(mtr.o)
>       _PetscSequentialPhaseBegin_Private in libpetsc.a(mpiu.o)
>       _PetscSequentialPhaseEnd_Private in libpetsc.a(mpiu.o)
>       _PetscSignalHandler_Private in libpetsc.a(signal.o)
>       _PetscSignalHandler_Private in libpetsc.a(signal.o)
>       _PetscDefaultSignalHandler in libpetsc.a(signal.o)
>       _PetscMPIAbortErrorHandler in libpetsc.a(errstop.o)
>       _PetscDefaultFPTrap in libpetsc.a(fp.o)
>   "_Petsc_MPI_Comm_dup", referenced from:
>       _PetscFinalize in libpetsc.a(pinit.o)
>       _PetscSequentialPhaseBegin in libpetsc.a(mpiu.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>   "_Petsc_MPI_Init", referenced from:
>       _PetscInitialize in libpetsc.a(pinit.o)
>   "PetscOptionsGetTruth(char const*, char const*, PetscTruth*,
> PetscTruth*)", referenced from:
>       PetscOptionsGetTruth(char const*, PetscTruth*, PetscTruth*)in
> ccPG7mg3.o
>   "PetscInitialize(int*, char***, char const*, char const*)", referenced
> from:
>       PetscInitialize(int*, char***)in ccPG7mg3.o
>       _main in ccPG7mg3.o
>   "_MPIUNI_TMP", referenced from:
>       _MPIUNI_TMP$non_lazy_ptr in ccPG7mg3.o
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(pinit.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(mprint.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(init.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(options.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(plog.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(mpinit.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(err.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(mtr.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(mpiu.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(verboseinfo.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(adebug.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(binv.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(filev.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(eventLog.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(view.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(pdisplay.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(tagm.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(mpiuopen.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(draw.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(sysio.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(pbarrier.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(dupl.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(fretrieve.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(send.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(dscatter.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(petscvu.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(axis.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(random.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(drawv.o)
>       _MPIUNI_TMP$non_lazy_ptr in libpetsc.a(lg.o)
>   "PetscOptionsGetScalar(char const*, char const*, double*, PetscTruth*)",
> referenced from:
>       PetscOptionsGetScalar(char const*, double*, PetscTruth*)in ccPG7mg3.o
>   "_Petsc_MPI_Keyval_create", referenced from:
>       _PetscViewerASCIIGetStdout in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIGetStderr in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIOpen in libpetsc.a(vcreatea.o)
>       _PetscSequentialPhaseBegin in libpetsc.a(mpiu.o)
>       _PETSC_VIEWER_BINARY_ in libpetsc.a(binv.o)
>       _PetscViewerDestroy_ASCII in libpetsc.a(filev.o)
>       _PetscCommGetNewTag in libpetsc.a(tagm.o)
>       _PetscCommGetNewTag in libpetsc.a(tagm.o)
>       _PetscCommGetNewTag in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscSharedTmp in libpetsc.a(fretrieve.o)
>       _PetscSharedWorkingDirectory in libpetsc.a(fretrieve.o)
>       _PETSC_VIEWER_SOCKET_ in libpetsc.a(send.o)
>       _PETSC_VIEWER_DRAW_ in libpetsc.a(drawv.o)
>   "_Petsc_MPI_Attr_delete", referenced from:
>       _PetscSequentialPhaseEnd in libpetsc.a(mpiu.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>   "_Petsc_MPI_Attr_get", referenced from:
>       _PetscViewerASCIIGetStdout in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIGetStderr in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIOpen in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIOpen in libpetsc.a(vcreatea.o)
>       _PetscSequentialPhaseEnd in libpetsc.a(mpiu.o)
>       _PETSC_VIEWER_BINARY_ in libpetsc.a(binv.o)
>       _PetscViewerDestroy_ASCII in libpetsc.a(filev.o)
>       _PetscCommGetNewTag in libpetsc.a(tagm.o)
>       _PetscCommGetNewTag in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>       _PetscSharedTmp in libpetsc.a(fretrieve.o)
>       _PetscSharedWorkingDirectory in libpetsc.a(fretrieve.o)
>       _PETSC_VIEWER_SOCKET_ in libpetsc.a(send.o)
>       _PETSC_VIEWER_DRAW_ in libpetsc.a(drawv.o)
>   "_Petsc_MPI_Attr_put", referenced from:
>       _PetscViewerASCIIGetStdout in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIGetStderr in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIOpen in libpetsc.a(vcreatea.o)
>       _PetscViewerASCIIOpen in libpetsc.a(vcreatea.o)
>       _PetscSequentialPhaseBegin in libpetsc.a(mpiu.o)
>       _PETSC_VIEWER_BINARY_ in libpetsc.a(binv.o)
>       _PetscViewerDestroy_ASCII in libpetsc.a(filev.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscCommDuplicate in libpetsc.a(tagm.o)
>       _PetscSharedTmp in libpetsc.a(fretrieve.o)
>       _PetscSharedWorkingDirectory in libpetsc.a(fretrieve.o)
>       _PETSC_VIEWER_SOCKET_ in libpetsc.a(send.o)
>       _PETSC_VIEWER_DRAW_ in libpetsc.a(drawv.o)
>   "PetscOptionsGetString(char const*, char const*, char*, unsigned long,
> PetscTruth*)", referenced from:
>       PetscOptionsGetString(char const*, char*, unsigned long,
> PetscTruth*)in ccPG7mg3.o
>   "_Petsc_MPI_Finalize", referenced from:
>       _PetscFinalize in libpetsc.a(pinit.o)
>       _Petsc_MPI_DebuggerOnError in libpetsc.a(init.o)
>       _PetscAttachDebuggerErrorHandler in libpetsc.a(adebug.o)
>   "PetscOptionsGetRealArray(char const*, char const*, double*, int*,
> PetscTruth*)", referenced from:
>       PetscOptionsGetRealArray(char const*, double*, int*, PetscTruth*)in
> ccPG7mg3.o
>   "PetscOptionsGetInt(char const*, char const*, int*, PetscTruth*)",
> referenced from:
>       PetscOptionsGetInt(char const*, int*, PetscTruth*)in ccPG7mg3.o
>   "PetscViewerCreate(int, _p_PetscViewer**)", referenced from:
>       PetscViewerCreate(_p_PetscViewer**)      in ccPG7mg3.o
>   "_Petsc_MPI_Comm_free", referenced from:
>       _PetscFinalize in libpetsc.a(pinit.o)
>       _PetscSequentialPhaseEnd in libpetsc.a(mpiu.o)
>       _PetscCommDestroy in libpetsc.a(tagm.o)
>   "PetscFinalize()", referenced from:
>       _main in ccPG7mg3.o
>   "PetscOptionsHasName(char const*, char const*, PetscTruth*)", referenced
> from:
>       PetscOptionsHasName(char const*, PetscTruth*)in ccPG7mg3.o
>   "PetscOptionsGetStringArray(char const*, char const*, char**, int*,
> PetscTruth*)", referenced from:
>       PetscOptionsGetStringArray(char const*, char**, int*, PetscTruth*)in
> ccPG7mg3.o
>   "_MPIUNI_Memcpy", referenced from:
>       _PetscMaxSum in libpetsc.a(pinit.o)
>       _PetscFinalize in libpetsc.a(pinit.o)
>       _PetscGlobalMax in libpetsc.a(pinit.o)
>       _PetscGlobalMin in libpetsc.a(pinit.o)
>       _PetscGlobalSum in libpetsc.a(pinit.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintSummary in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscLogPrintDetailed in libpetsc.a(plog.o)
>       _PetscIntView in libpetsc.a(err.o)
>       _PetscIntView in libpetsc.a(err.o)
>       _PetscIntView in libpetsc.a(err.o)
>       _PetscIntView in libpetsc.a(err.o)
>       _PetscRealView in libpetsc.a(err.o)
>       _PetscRealView in libpetsc.a(err.o)
>       _PetscRealView in libpetsc.a(err.o)
>       _PetscRealView in libpetsc.a(err.o)
>       _PetscScalarView in libpetsc.a(err.o)
>       _PetscScalarView in libpetsc.a(err.o)
>       _PetscScalarView in libpetsc.a(err.o)
>       _PetscScalarView in libpetsc.a(err.o)
>       _PetscSharedTmp in libpetsc.a(fretrieve.o)
>       _PetscSharedWorkingDirectory in libpetsc.a(fretrieve.o)
>   "_Petsc_MPI_Initialized", referenced from:
>       _PetscInitialize in libpetsc.a(pinit.o)
>   "PetscOptionsGetIntArray(char const*, char const*, int*, int*,
> PetscTruth*)", referenced from:
>       PetscOptionsGetIntArray(char const*, int*, int*, PetscTruth*)in
> ccPG7mg3.o
>   "PetscSequentialPhaseBegin(int, int)", referenced from:
>       PetscSequentialPhaseBegin(int)  in ccPG7mg3.o
>       PetscSequentialPhaseBegin()     in ccPG7mg3.o
>   "PetscSequentialPhaseEnd(int, int)", referenced from:
>       PetscSequentialPhaseEnd(int)  in ccPG7mg3.o
>       PetscSequentialPhaseEnd()     in ccPG7mg3.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> 
> Is this a problem with my libpetsc.a?  Or is this problem because another
> library is broken or not being linked to?  Any insight into this problem
> would be greatly appreciated.  After several hours of trying to figure this
> out I feel like I'm lost at sea.
> 
> 
> Charles
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Postscript:
> 
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h: In function
> ‘PetscErrorCode PetscViewerCreate(_p_PetscViewer**)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h:117: error:
> declaration of C function ‘PetscErrorCode
> PetscViewerCreate(_p_PetscViewer**)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h:116: error:
> previous declaration ‘PetscErrorCode PetscViewerCreate(MPI_Comm,
> _p_PetscViewer**)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h: In function
> ‘PetscErrorCode PetscViewerCreate(_p_PetscViewer**)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h:117: error: invalid
> conversion from ‘int’ to ‘_p_PetscViewer**’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h:117: error: too
> many arguments to function ‘PetscErrorCode
> PetscViewerCreate(_p_PetscViewer**)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscviewer.h:117: error: at this
> point in file
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsHasName(const char*, PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:10: error:
> declaration of C function ‘PetscErrorCode PetscOptionsHasName(const char*,
> PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:9: error: previous
> declaration ‘PetscErrorCode PetscOptionsHasName(const char*, const char*,
> PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsHasName(const char*, PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:10: error: cannot
> convert ‘const char*’ to ‘PetscTruth*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsHasName(const char*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetInt(const char*, PetscInt*, PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:12: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetInt(const char*,
> PetscInt*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:11: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetInt(const char*, const
> char*, PetscInt*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetInt(const char*, PetscInt*, PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:12: error: cannot
> convert ‘const char*’ to ‘PetscInt*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetInt(const char*, PetscInt*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetTruth(const char*, PetscTruth*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:14: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetTruth(const char*,
> PetscTruth*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:13: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetTruth(const char*, const
> char*, PetscTruth*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetTruth(const char*, PetscTruth*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:14: error: cannot
> convert ‘const char*’ to ‘PetscTruth*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetTruth(const char*, PetscTruth*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetReal(const char*, PetscReal*, PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:16: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetReal(const char*,
> PetscReal*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:15: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetReal(const char*, const
> char*, PetscReal*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetReal(const char*, PetscReal*, PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:16: error: cannot
> convert ‘const char*’ to ‘PetscReal*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetReal(const char*, PetscReal*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetScalar(const char*, PetscScalar*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:18: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetScalar(const char*,
> PetscScalar*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:17: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetScalar(const char*,
> const char*, PetscScalar*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetScalar(const char*, PetscScalar*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:18: error: cannot
> convert ‘const char*’ to ‘PetscScalar*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetScalar(const char*, PetscScalar*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetIntArray(const char*, PetscInt*, PetscInt*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:20: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetIntArray(const
> char*, PetscInt*, PetscInt*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:19: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetIntArray(const char*,
> const char*, PetscInt*, PetscInt*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetIntArray(const char*, PetscInt*, PetscInt*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:20: error: cannot
> convert ‘const char*’ to ‘PetscInt*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetIntArray(const char*, PetscInt*, PetscInt*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetRealArray(const char*, PetscReal*, PetscInt*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:22: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetRealArray(const
> char*, PetscReal*, PetscInt*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:21: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetRealArray(const char*,
> const char*, PetscReal*, PetscInt*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetRealArray(const char*, PetscReal*, PetscInt*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:22: error: cannot
> convert ‘const char*’ to ‘PetscReal*’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetRealArray(const char*, PetscReal*, PetscInt*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetString(const char*, char*, size_t,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:24: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetString(const char*,
> char*, size_t, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:23: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetString(const char*,
> const char*, char*, size_t, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetString(const char*, char*, size_t,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:24: error: invalid
> conversion from ‘const char*’ to ‘char*’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:24: error: invalid
> conversion from ‘char*’ to ‘size_t’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:24: error: invalid
> conversion from ‘size_t’ to ‘PetscTruth*’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:24: error: too
> many arguments to function ‘PetscErrorCode PetscOptionsGetString(const
> char*, char*, size_t, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:24: error: at this
> point in file
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetStringArray(const char*, char**, PetscInt*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:26: error:
> declaration of C function ‘PetscErrorCode PetscOptionsGetStringArray(const
> char*, char**, PetscInt*, PetscTruth*)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:25: error:
> previous declaration ‘PetscErrorCode PetscOptionsGetStringArray(const char*,
> const char*, char**, PetscInt*, PetscTruth*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h: In function
> ‘PetscErrorCode PetscOptionsGetStringArray(const char*, char**, PetscInt*,
> PetscTruth*)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petscoptions.h:26: error: cannot
> convert ‘const char*’ to ‘char**’ for argument ‘2’ to ‘PetscErrorCode
> PetscOptionsGetStringArray(const char*, char**, PetscInt*, PetscTruth*)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscInitialize(int*, char***)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1160: error: declaration
> of C function ‘PetscErrorCode PetscInitialize(int*, char***)’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1159: error: previous
> declaration ‘PetscErrorCode PetscInitialize(int*, char***, const char*,
> const char*)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscInitialize(int*, char***)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1160: error: too many
> arguments to function ‘PetscErrorCode PetscInitialize(int*, char***)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1160: error: at this
> point in file
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1347: error: declaration
> of C function ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’ conflicts
> with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1346: error: previous
> declaration ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,
> PetscMPIInt)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1347: error: too many
> arguments to function ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1347: error: at this
> point in file
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseBegin()’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1348: error: declaration
> of C function ‘PetscErrorCode PetscSequentialPhaseBegin()’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1347: error: previous
> declaration ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1348: error: too many
> arguments to function ‘PetscErrorCode PetscSequentialPhaseBegin()’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1348: error: at this
> point in file
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1350: error: declaration
> of C function ‘PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm)’ conflicts
> with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1349: error: previous
> declaration ‘PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm, PetscMPIInt)’
> here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1350: error: too many
> arguments to function ‘PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm)’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1350: error: at this
> point in file
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseEnd()’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1351: error: declaration
> of C function ‘PetscErrorCode PetscSequentialPhaseEnd()’ conflicts with
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1350: error: previous
> declaration ‘PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm)’ here
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h: In function
> ‘PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1351: error: too many
> arguments to function ‘PetscErrorCode PetscSequentialPhaseEnd()’
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1351: error: at this
> point in file
> Laplace.cc: In function ‘int main(int, char**)’:
> /Users/charles/pkg/petsc-2.3.3-p15/include/petsc.h:1160: error: too many
> arguments to function ‘PetscErrorCode PetscInitialize(int*, char***)’
> Laplace.cc:206: error: at this point in file
> 
> 
> This last error doesn't even make sense, as it conforms to the usage
> specified here (
> http://www.mcs.anl.gov/petsc/petsc-2/snapshots/petsc-dev/docs/manualpages/Sys/PetscInitialize.html
> ).
> 


More information about the petsc-users mailing list