Thanks a lot for the explanation. I will simply leave the makefile in the same directory of codes to avoid making mistakes.<div><br></div><div>best,</div><div>Alan<br><div><br><div class="gmail_quote">On Thu, Aug 25, 2011 at 2:01 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
ComputeRHS.o: Programs/ComputeRHS.c Programs/ComputeRHS.h Programs/def.h chkopts<br>
-${CLINKER} -o ComputerRHS.o Programs/ComputeRHS.c ${PETSC_SNES_LIB}<br>
<br>
Don't use the CLINKER to compile code. That is only for linking the executable. So for example you should be able to us<br>
<br>
myprogram: Programs/ComputeRHS.o<br>
-${CLINKER} -o myprogram Programs/ComputeRHS.o ${PETSC_SNES_LIB}<br>
<br>
Also it generally is much easier to have make files that site in the same directory as the source code, less hassle and less likely for things to go wrong.<br>
<br>
Barry<br>
<div><div></div><div class="h5"><br>
<br>
On Aug 25, 2011, at 1:56 PM, Alan Wei wrote:<br>
<br>
> Dear all,<br>
> I hope you're having a nice day.<br>
> I met a problem on makefile of PETSc. Original PETSc has the makefile in the same directory of the .c files. However, I want to put all .c files to another directory. I changed the makefile also; however it always has a error saying the PETSc header files can not be found:<br>
><br>
> /home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/bin/mpicc -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g3 -o ComputerRHS.o Programs/ComputeRHS.c -L/home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/lib -lpetsc -Wl,-rpath,/home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/lib -lflapack -lfblas -lm -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -ldl -lmpich -lopa -lmpl -lrt -lpthread -lgcc_s -lmpichf90 -lgfortran -lm -lm -ldl -lmpich -lopa -lmpl -lrt -lpthread -lgcc_s -ldl<br>
> Programs/ComputeRHS.c:1:23: error: petscdmda.h: No such file or directory<br>
> Programs/ComputeRHS.c:2:22: error: petscksp.h: No such file or directory<br>
> Programs/ComputeRHS.c:3:23: error: petscpcmg.h: No such file or directory<br>
> Programs/ComputeRHS.c:4:23: error: petscdmmg.h: No such file or directory<br>
> In file included from Programs/ComputeRHS.c:5:<br>
> Programs/def.h:6:22: error: petscsys.h: No such file or directory<br>
> In file included from Programs/ComputeRHS.c:5:<br>
> Programs/def.h:25: error: expected specifier-qualifier-list before PetscReal<br>
> Programs/def.h:29: error: expected specifier-qualifier-list before PetscScalar<br>
> Programs/def.h:35: error: expected specifier-qualifier-list before PetscInt<br>
> Programs/def.h:41: error: expected specifier-qualifier-list before PetscScalar<br>
> Programs/ComputeRHS.c:10: error: expected =, ,, ;, asm or __attribute__ before ComputeRHS<br>
> make: [ComputeRHS.o] Error 1 (ignored)<br>
> make: *** No rule to make target `Initialization.o', needed by `ex29'. Stop.<br>
><br>
> My codes are attached. Could you please help me to figure this out?<br>
><br>
> thanks,<br>
> Alan<br>
</div></div>> <MakeFileProblem.zip><br>
<br>
</blockquote></div><br></div></div>