link with other libraries

Satish Balay balay at mcs.anl.gov
Fri Jul 21 12:49:37 CDT 2006


The basic form of a PETSc makefile is as follows:

>>>>>>
CFLAGS           =
FFLAGS           =
CPPFLAGS         =
FPPFLAGS         =
CLEANFILES       =

include ${PETSC_DIR}/bmake/common/base

ex1: ex1.o  chkopts
        -${CLINKER} -o ex1 ex1.o  ${PETSC_KSP_LIB}
        ${RM} ex1.o
>>>>>>>>>>


If you wish to specify additonal libraries - you can do it as:


>>>>>>>
MY_INC          = -I/my/include
MY_LIB          = -L/my/lib -lmy

CFLAGS           =
FFLAGS           =
CPPFLAGS         = ${MY_INC}
FPPFLAGS         =
CLEANFILES       =

include ${PETSC_DIR}/bmake/common/base

ex1: ex1.o  chkopts
        -${CLINKER} -o ex1 ex1.o  ${MY_LIB} ${PETSC_KSP_LIB}
        ${RM} ex1.o
>>>>>>>>>

Also - you should make sure this library is compiled with the same
compilers as PETSc is compiled with.

Satish

On Fri, 21 Jul 2006, jordi poblet wrote:

> Dear all,
> 
> I would like to use PETSc within a finite element program (the main part is
> written in C++). Some classes should use PETSc routines and routines from
> other libraries. When compiling these classes, I have to include not only
> the header files from PETSc (which in the examples of a single C or C++
> files are included automatically with the sample makefiles provided in the
> manual) but also header files from the other used libraries. Finally, I
> would have also to link PETSc with other libraries at the same time.
> I have tried to construct a makefile including 'by hand' the PETSc headers
> but I have always problems. Could someone help me? Have you got makefile
> examples for this situation (or similar)?
> 
> The compilation options for the PETSc library that I have employed are:
> 
> ./config/configure.py --with-mpi=0 --with-clanguage=c++
> --with-scalar-type=complex
> 
> tests and examples are passed correctly.
> 
> I am running PETSc in linux machines.
> 
> 
> Thank you in advance,
> 
> Jordi Poblet
> 




More information about the petsc-users mailing list