<div dir="ltr"><div dir="ltr"><div dir="ltr">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.            </div><div dir="ltr">It seems that ${CLINKER} can automatically identify the extension of files and compile them with different compilers. <br></div><div dir="ltr"><br></div><div dir="ltr">Thanks for helping me.<br></div><div>Yingjie</div></div></div><br><div class="gmail_quote"><div dir="ltr">Balay, Satish <<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>> 于2018年10月24日周三 下午11:35写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please send complete logs. [i.e the complete compile output from your makefile. Also send your makefile]<br>
<br>
If your c++ code uses .cxx - it should get compiled with a c++ compiler.<br>
<br>
You might benefit by change CLINKER to CXXLINKER<br>
<br>
Satish<br>
<br>
On Wed, 24 Oct 2018, Yingjie Wu wrote:<br>
<br>
> Thank you very much for your reply.<br>
> <br>
> Because the files I added are written in c++, including definitions of<br>
> classes and functions. I encountered a mistake when I used your method.<br>
> myprogram: class1.o myprogram.o<br>
>        ${CLINKER} -o myprogram class1.o myprogram.o ${PETSC_LIB}<br>
> Error information is : unknown type name 'class'<br>
> It seems that I did not compile using the c++ compiler.<br>
> <br>
> How should I set it up so that it can compile successfully?<br>
> <br>
> Thanks,<br>
> Yingjie<br>
> <br>
> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> 于2018年10月24日周三 上午1:46写道:<br>
> <br>
> > On Tue, Oct 23, 2018 at 11:37 AM Yingjie Wu <<a href="mailto:yjwu16@gmail.com" target="_blank">yjwu16@gmail.com</a>> wrote:<br>
> ><br>
> >> Dear Petsc developer:<br>
> >> Hi,<br>
> >> Thank you very much for your continuous help, I recently encountered some<br>
> >> difficulties in developing programs on Petsc.<br>
> >><br>
> >> 1. I want to use my class definition (class1. h) and class functions<br>
> >> (class1. cpp) files in my Petsc program (myprogram. c) and compile my<br>
> >> program. I have written other program before:<br>
> >> g++ -c class1.cpp myprogram.c<br>
> >> g++ -o myprogram *.o<br>
> >> I also have some knowledge of Makefile, but I don't know how to modify it<br>
> >> to achieve compilation. I really want your help.<br>
> >><br>
> ><br>
> > With PETSc makefiles, we have automatic rules, so you can use<br>
> ><br>
> > myprogram: class1.o myprogram.o<br>
> >        ${CLINKER} -o myprogram class1.o myprogram.o ${PETSC_LIB}<br>
> ><br>
> ><br>
> >> 2.  In my class definition and function implementation program, I want to<br>
> >> use Petsc data structures, such as PetscInt, PetscReal. In order to<br>
> >> maintain consistency of the main program. What kind of header files should<br>
> >> I add to my code, or do I need to add any code?<br>
> >><br>
> ><br>
> > The easiest thing to do is just<br>
> ><br>
> > #include <petsc.h><br>
> ><br>
> >   Thanks,<br>
> ><br>
> >     Matt<br>
> ><br>
> ><br>
> >> Thanks,<br>
> >> Yingjie<br>
> >><br>
> ><br>
> ><br>
> > --<br>
> > What most experimenters take for granted before they begin their<br>
> > experiments is infinitely more interesting than any results to which their<br>
> > experiments lead.<br>
> > -- Norbert Wiener<br>
> ><br>
> > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> ><br>
> <br>
</blockquote></div>