how to use PETSC with C++
Tomasz Jankowski
tomjan at jay.au.poznan.pl
Tue Feb 7 05:57:16 CST 2006
hello group
I know that no-one like newbie questions, but... unfortunetly I have one
Sorry but I cant find in google or manual the clear example how to use
PETSC from C++.
If there are such, please just point me to them.
Initaially I have started with
./config/configure.py --download-f-blas-lapack=1
I have sucessfully compiled a few examples and run in parallel mode.
Now I want to implement PETSC for solwing my linear models.
I need to switch to C++ because whole code for data manipulation
(reading,renumbering) and model manipulation (representation, building) I
have written in C++.
Maybe it is strange that I'm writing c/c++ code and have such problems but
(i'm geneticst not informaticst) compiling and linking ,static and shared
libs building it is just night mare for me.
So,
I have configured PETSC with such options
Configure Options: --with-clanguage=C++ --download-f-blas-lapack=1
--with-shared=0 -configModules=PETSc.Configure
and can't compile even such code
-------------------------------------------
#include <string>
#include "petscksp.h"
#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc,char **args)
{
PetscErrorCode ierr;
PetscInitialize(argc,args,PETSC_NULL,PETSC_NULL);
ierr = PetscFinalize();
CHKERRQ(ierr);
return 0;
}
----------------------------------------
When I try to compile it I obtain this:
mpiCC -c -Wall -g3 -I/home/work/petsc-2.3.0
-I/home/work/petsc-2.3.0/bmake/linux-gnu -I/home/work/petsc-2.3.0/include
-I/usr/local/include -D__SDIR__="/home/work/blup_pcg" ex4.C
mpiCC -Wall -g3 -o ex4 ex4.o
-Wl,-rpath,/home/work/petsc-2.3.0/lib/linux-gnu
-L/home/work/petsc-2.3.0/lib/linux-gnu -lpetscksp -lpetscdm -lpetscmat
-lpetscvec -lpetsc -lnsl -lrt
-Wl,-rpath,/home/work/petsc-2.3.0/externalpackages/fblaslapack/linux-gnu
-L/home/work/petsc-2.3.0/externalpackages/fblaslapack/linux-gnu-lflapack
-Wl,-rpath,/home/work/petsc-2.3.0/externalpackages/fblaslapack/linux-gnu
-L/home/work/petsc-2.3.0/externalpackages/fblaslapack/linux-gnu -lfblas
-lm -L/usr/local/lib -llammpio -llamf77mpi -lmpi -llam -lutil -ldl -lg2c
-lm -L/usr/lib/gcc-lib/i486-linux/3.3.5
-L/usr/lib/gcc-lib/i486-linux/3.3.5/../../.. -lm -lgcc_s -lpthread
-L/usr/local/lib -L/usr/lib/gcc-lib/i486-linux/3.3.5
-L/usr/lib/gcc-lib/i486-linux/3.3.5/../../.. -llammpio -llammpi++
-llamf77mpi -lmpi -llam -lutil -ldl -lstdc++ -lgcc_s -lpthread
ex4.o(.text+0x2e): In function `main':
/usr/local/include/mpi2cxx/datatype_inln.h:174: undefined reference to
`PetscInitialize(int*, char***, char const*, char const*)'
ex4.o(.text+0x33):/usr/local/include/mpi2cxx/datatype_inln.h:213:
undefined reference to `PetscFinalize()'
collect2: ld returned 1 exit status
mpiCC: No such file or directory
make: [ex4] B³±d 1 (zignorowany)
########################################################
# tomjan at jay.au.poznan.pl #
# jay.au.poznan.pl/~tomjan/ #
########################################################
More information about the petsc-users
mailing list