[petsc-users] Problems about Compiling Multifile Program

Yingjie Wu yjwu16 at gmail.com
Wed Oct 24 10:48:15 CDT 2018


Sorry, I made a mistake. I have a.C file with the same name in the current
directory. When I remove it, the compiler can be passed.
It seems that ${CLINKER} can automatically identify the extension of files
and compile them with different compilers.

Thanks for helping me.
Yingjie

Balay, Satish <balay at mcs.anl.gov> 于2018年10月24日周三 下午11:35写道:

> Please send complete logs. [i.e the complete compile output from your
> makefile. Also send your makefile]
>
> If your c++ code uses .cxx - it should get compiled with a c++ compiler.
>
> You might benefit by change CLINKER to CXXLINKER
>
> Satish
>
> On Wed, 24 Oct 2018, Yingjie Wu wrote:
>
> > Thank you very much for your reply.
> >
> > Because the files I added are written in c++, including definitions of
> > classes and functions. I encountered a mistake when I used your method.
> > myprogram: class1.o myprogram.o
> >        ${CLINKER} -o myprogram class1.o myprogram.o ${PETSC_LIB}
> > Error information is : unknown type name 'class'
> > It seems that I did not compile using the c++ compiler.
> >
> > How should I set it up so that it can compile successfully?
> >
> > Thanks,
> > Yingjie
> >
> > Matthew Knepley <knepley at gmail.com> 于2018年10月24日周三 上午1:46写道:
> >
> > > On Tue, Oct 23, 2018 at 11:37 AM Yingjie Wu <yjwu16 at gmail.com> wrote:
> > >
> > >> Dear Petsc developer:
> > >> Hi,
> > >> Thank you very much for your continuous help, I recently encountered
> some
> > >> difficulties in developing programs on Petsc.
> > >>
> > >> 1. I want to use my class definition (class1. h) and class functions
> > >> (class1. cpp) files in my Petsc program (myprogram. c) and compile my
> > >> program. I have written other program before:
> > >> g++ -c class1.cpp myprogram.c
> > >> g++ -o myprogram *.o
> > >> I also have some knowledge of Makefile, but I don't know how to
> modify it
> > >> to achieve compilation. I really want your help.
> > >>
> > >
> > > With PETSc makefiles, we have automatic rules, so you can use
> > >
> > > myprogram: class1.o myprogram.o
> > >        ${CLINKER} -o myprogram class1.o myprogram.o ${PETSC_LIB}
> > >
> > >
> > >> 2.  In my class definition and function implementation program, I
> want to
> > >> use Petsc data structures, such as PetscInt, PetscReal. In order to
> > >> maintain consistency of the main program. What kind of header files
> should
> > >> I add to my code, or do I need to add any code?
> > >>
> > >
> > > The easiest thing to do is just
> > >
> > > #include <petsc.h>
> > >
> > >   Thanks,
> > >
> > >     Matt
> > >
> > >
> > >> Thanks,
> > >> Yingjie
> > >>
> > >
> > >
> > > --
> > > What most experimenters take for granted before they begin their
> > > experiments is infinitely more interesting than any results to which
> their
> > > experiments lead.
> > > -- Norbert Wiener
> > >
> > > https://www.cse.buffalo.edu/~knepley/
> > > <http://www.cse.buffalo.edu/~knepley/>
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181024/9f4b2f9d/attachment.html>


More information about the petsc-users mailing list