[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables
Satish Balay
balay at mcs.anl.gov
Thu Aug 5 10:48:18 CDT 2010
The idea here is - you would:
include "conf/variables" in your makefile and use PETSC_LIB in the
target - so everything works correctly.
The complexity you mention is to manage --with-single-lib=0/1. So
Instead of trying to list libraries directly in your makefile [which
becomes unportable] - I suggest you use the recommended procedure
above. PETSC_LIB will pick up all exteranlpackages currently installed
with PETSc [so even this part of the makefile will become portable]
The best thing would be to also use "conf/rules" as well in your
makefile and use PETSc compile targets for both petsc & non-petsc
sources that go into your application.
Satish
On Thu, 5 Aug 2010, Filippo Spiga wrote:
> Dear users,
> I look at different examples but I'm not sure to have well understood how
> to compile and link correctly using the contents of "conf/petscvariables" and
> "conf/variables". My program uses both linear and non linear solvers and
> different external packages such as superlu_dist, hypre and umfpack. I looked
> at "${PETSC_ROOT}/${PETSC_ARCH}/conf/petscvariables" to extract the right path
> to compile and link my code. Inside this file there are all these lines:
>
> PETSC_CONTRIB_BASIC = -lpetsc
> PETSC_SNES_LIB_BASIC = -lpetsc
> PETSC_KSP_LIB_BASIC = -lpetsc
> PETSC_MAT_LIB_BASIC = -lpetsc
> PETSC_LIB_BASIC = -lpetsc
> PETSC_VEC_LIB_BASIC = -lpetsc
> PETSC_DM_LIB_BASIC = -lpetsc
> PETSC_TS_LIB_BASIC = -lpetsc
> PETSC_SYS_LIB_BASIC = -lpetsc
> PACKAGES_LIBS = ...
>
> but there isn't a single entry that collect in the right order all of them.
> Then if I look at "${PETSC_ROOT}/${PETSC_ARCH}/conf/variables" I can find
> these lines:
>
> PETSC_EXTERNAL_LIB_BASIC = ${EXTERNAL_LIB} ${PACKAGES_LIBS} ${PCC_LINKER_LIBS}
> PETSC_SYS_LIB_BASIC = -lpetscsys
> PETSC_VEC_LIB_BASIC = -lpetscvec ${PETSC_SYS_LIB_BASIC}
> PETSC_MAT_LIB_BASIC = -lpetscmat ${PETSC_VEC_LIB_BASIC}
> PETSC_DM_LIB_BASIC = -lpetscdm ${PETSC_MAT_LIB_BASIC}
> PETSC_KSP_LIB_BASIC = -lpetscksp ${PETSC_DM_LIB_BASIC}
> PETSC_SNES_LIB_BASIC = -lpetscsnes ${PETSC_KSP_LIB_BASIC}
> PETSC_TS_LIB_BASIC = -lpetscts ${PETSC_SNES_LIB_BASIC}
> PETSC_LIB_BASIC = ${PETSC_TS_LIB_BASIC}
> PETSC_CONTRIB_BASIC = -lpetsccontrib
>
> PETSC_SYS_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_SYS_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_VEC_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_VEC_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_MAT_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_MAT_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_DM_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_DM_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_KSP_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_KSP_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_SNES_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR}
> ${PETSC_SNES_LIB_BASIC} ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_TS_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_TS_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_LIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_LIB_BASIC}
> ${PETSC_EXTERNAL_LIB_BASIC}
> PETSC_CONTRIB = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} ${PETSC_CONTRIB_BASIC}
>
> that are pretty clear. However if I look inside
> "${PETSC_ROOT}/${PETSC_ARCH}/lib" I don't see all the -lpetsc* libraries
> mentioned above" I only have one single "libpetsc.a"
>
> So, what's the right env variable to use? what is the right order of -lpetsc*
> statements? Can I only link "libpetsc.a"? In this last case, is my Makefile
> fully compatible and maintenable with all the future version of PETSc?
>
> Thank you very much in advance,
> Regards
>
>
More information about the petsc-users
mailing list