PETSc linking

The easiest way to link PETSc to your code is to have this line in your makefile:

include ${PETSC_DIR}/conf/base

This will automatically give you the compilation rules. For linking you then do:

${CLINKER} -o ex1 ex1.o ${PETSC_LIB}

(or FLINKER for fortran)

You can also use this include line:

include ${PETSC_DIR}/conf/variables

and then you have to give the compile rules yourself. In this case, do
something like

${CC} -c ex1.c ${PETSC_INCLUDE}

to compile. (This is for petsc version 3, for version 2 use

include ${PETSC_DIR}/bmake/common/base

and replace base by variables to omit petsc’s make rules.)

If you insist on having all the libraries and includes explicitly, use

make getlinklibs
make getincludedirs