link with other libraries
jordi poblet
jordi.poblet at gmail.com
Fri Jul 21 13:45:42 CDT 2006
Satish,
Thank you very much for your fast response. It has solved the problem with
including files and I can generate the object file for my class (myclass.o).
However, I suppose that with
ex1: myclass.o chkopts
-${CLINKER} -o ex1 myclass.o ${MY_LIB} ${PETSC_KSP_LIB}
${RM} myclass.o
the makefile is trying to link a self executable program (ex1) and I
obtain the following error message:
: undefined reference to `main'
(in myclass.cpp there is no main block, the class is used by main.cpp).
I would like,
1-compile the class and obtain the file myclass.o (now I can do it with the
error shown above, but the file is at least generated) taking into account
the correct includes (from PETSc and from other libraries). I do not need
the libraries in this step
2-compile all the other classes not using PETSc and obtain the other files
*.o
3-link all the files *.o and myclass.o taking into account all the libraries
Thank you very much. Best regards,
Jordi Poblet
On 7/21/06, Satish Balay <balay at mcs.anl.gov> wrote:
>
> 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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20060721/1731006d/attachment.htm>
More information about the petsc-users
mailing list