4
$\begingroup$

I'm having a problem where petsc is complaining about the type of PetscScalar (I get a whole bunch of errors from the c++ standard library that revolve around PetscScalar not defined).

I believe it is a problem with the way Petsc is compliled (I vaguely remember that Petsc can't seem to have both --with-c-support and --with-c++-support along with --with-scalar-type=complex, but I can't seem to figure out where that is stated.)

A sample of the errors I get (full version at pastebin):

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:550: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double std::__complex_abs(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:569: error: declaration of C function ‘double std::__complex_abs(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:566: error: previous declaration ‘float std::__complex_abs(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double std::__complex_abs(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:572: error: declaration of C function ‘long double std::__complex_abs(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:569: error: previous declaration ‘double std::__complex_abs(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:575: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:586: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double std::__complex_arg(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:596: error: declaration of C function ‘double std::__complex_arg(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:593: error: previous declaration ‘float std::__complex_arg(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double std::__complex_arg(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:599: error: declaration of C function ‘long double std::__complex_arg(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:596: error: previous declaration ‘double std::__complex_arg(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:602: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:616: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:628: error: template specialization with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:639: error: template with C linkage
at-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_cos(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:674: error: declaration of C function ‘double __complex__ std::__complex_cos(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:671: error: previous declaration ‘float __complex__ std::__complex_cos(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_cos(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:677: error: declaration of C function ‘long double __complex__ std::__complex_cos(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:674: error: previous declaration ‘double __complex__ std::__complex_cos(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:680: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:690: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_cosh(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:704: error: declaration of C function ‘double __complex__ std::__complex_cosh(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:701: error: previous declaration ‘float __complex__ std::__complex_cosh(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_cosh(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:707: error: declaration of C function ‘long double __complex__ std::__complex_cosh(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:704: error: previous declaration ‘double __complex__ std::__complex_cosh(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:710: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:720: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_exp(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:730: error: declaration of C function ‘double __complex__ std::__complex_exp(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:727: error: previous declaration ‘float __complex__ std::__complex_exp(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_exp(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:733: error: declaration of C function ‘long double __complex__ std::__complex_exp(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:730: error: previous declaration ‘double __complex__ std::__complex_exp(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:736: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:747: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_log(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:757: error: declaration of C function ‘double __complex__ std::__complex_log(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:754: error: previous declaration ‘float __complex__ std::__complex_log(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_log(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:760: error: declaration of C function ‘long double __complex__ std::__complex_log(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:757: error: previous declaration ‘double __complex__ std::__complex_log(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:763: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:772: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:778: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_exp(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:792: error: declaration of C function ‘double __complex__ std::__complex_sin(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:789: error: previous declaration ‘float __complex__ std::__complex_sin(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_exp(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:795: error: declaration of C function ‘long double __complex__ std::__complex_sin(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:792: error: previous declaration ‘double __complex__ std::__complex_sin(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:798: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:808: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_sinh(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:822: error: declaration of C function ‘double __complex__ std::__complex_sinh(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:819: error: previous declaration ‘float __complex__ std::__complex_sinh(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_sinh(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:825: error: declaration of C function ‘long double __complex__ std::__complex_sinh(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:822: error: previous declaration ‘double __complex__ std::__complex_sinh(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:828: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:839: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_sqrt(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:866: error: declaration of C function ‘double __complex__ std::__complex_sqrt(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:863: error: previous declaration ‘float __complex__ std::__complex_sqrt(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_sqrt(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:869: error: declaration of C function ‘long double __complex__ std::__complex_sqrt(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:866: error: previous declaration ‘double __complex__ std::__complex_sqrt(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:872: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:883: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_tan(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:893: error: declaration of C function ‘double __complex__ std::__complex_tan(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:890: error: previous declaration ‘float __complex__ std::__complex_tan(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_tan(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:896: error: declaration of C function ‘long double __complex__ std::__complex_tan(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:893: error: previous declaration ‘double __complex__ std::__complex_tan(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:899: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:911: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘double __complex__ std::__complex_tanh(double __complex__)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:921: error: declaration of C function ‘double __complex__ std::__complex_tanh(double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:918: error: previous declaration ‘float __complex__ std::__complex_tanh(float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_tanh(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:924: error: declaration of C function ‘long double __complex__ std::__complex_tanh(const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:921: error: previous declaration ‘double __complex__ std::__complex_tanh(double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:927: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:940: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:945: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:960: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: In function ‘long double __complex__ std::__complex_tan(const long double __complex__&)’:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:971: error: declaration of C function ‘double __complex__ std::__complex_pow(double __complex__, double __complex__)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:967: error: previous declaration ‘float __complex__ std::__complex_pow(float __complex__, float __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:976: error: declaration of C function ‘long double __complex__ std::__complex_pow(const long double __complex__&, const long double __complex__&)’ conflicts with
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:971: error: previous declaration ‘double __complex__ std::__complex_pow(double __complex__, double __complex__)’ here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:979: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:990: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:1001: error: template specialization with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:1104: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:1113: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:1122: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:1131: error: template with C linkage
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/complex:1448: error: template with C linkage
/usr/local/petsc-3.2-p6/include/petscmath.h:92: error: expected initializer before ‘PetscScalar’
/usr/local/petsc-3.2-p6/include/petscmath.h:191: error: ‘PetscScalar’ does not name a type
/usr/local/petsc-3.2-p6/include/petscmath.h:347: warning: ‘PetscIsInfOrNanScalar’ initialized and declared ‘extern’
/usr/local/petsc-3.2-p6/include/petscmath.h:347: error: ‘PetscScalar’ was not declared in this scope
/usr/local/petsc-3.2-p6/include/petscmath.h:367: error: ‘PetscScalar’ does not name a type
/usr/local/petsc-3.2-p6/include/petscviewer.h:386: error: expected ‘,’ or ‘...’ before ‘*’ token
/usr/local/petsc-3.2-p6/include/petscviewer.h:386: error: ISO C++ forbids declaration of ‘PetscScalar’ with no type
/usr/local/petsc-3.2-p6/include/petscviewer.h:387: error: ‘PetscScalar’ has not been declared
make: [bin/etom] Error 1 (ignored)
#-/usr/local/mpich2/bin/mpicc -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g3  -o testmpi testmpi.o -lgsl  -L/usr/local/petsc-3.2-p6/lib  -lpetsc -lX11 -lpthread -llapack -lblas -L/central/intel/Compiler-11.1.072/mkl/lib/em64t -L/central/intel/Compiler-11.1.072/lib/intel64 -L/central/intel/Compiler-11.1.072/tbb/intel64/cc3.4.3_libc2.3.4_kernel2.6.9/lib -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -ldl -lgcc_s -lifport -lifcore -limf -lsvml -lm -lipgo -lirc -lpthread -lirc_s -lm -lstdc++ -lstdc++ -ldl -lgcc_s -ldl 
#/bin/rm -f -f testmpi.o
$\endgroup$
3
  • $\begingroup$ Please post your configure.log to pastebin as well. $\endgroup$ Feb 27, 2012 at 0:03
  • $\begingroup$ Is specific compilation advice on-topic here, or would this just be better on SO? $\endgroup$
    – F'x
    Feb 28, 2012 at 13:19
  • 1
    $\begingroup$ I was under the impression that library specific compilation/configuration issues were ok here. $\endgroup$ Mar 3, 2012 at 21:03

1 Answer 1

5
$\begingroup$

You have quite a lot of issues to address first. For example, your GSL headers are not being found and your compiler is set up in some strict configuration where it errors on long long. Perhaps this means you have set -pedantic -Werror. The environment may also be messed up or you might have a stray open extern "C" { around some header includes.

Note that you will generally have type issues passing complex numbers between C and C++. In practice, C99 complex (see complex.h) is binary-compatible with C++ complex, so you can cast and still use the same interface.

If you still need help with PETSc, please send configure.log and any relevant build output to [email protected].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.