On Thu, 7 Nov 2013, at 10:22, Jed Brown wrote: > Svetlana Tkachenko <svetlana.tkache...@fastmail.fm> writes: > > Right. I have spent half of an hour now trying to imagine what to do > > to link trying everything like a headless chicken and it did not > > work. > > You always have to send the error message. > > > I would appreciate if you could come up with something that links, not > > just runs a single program. > > The makefiles we suggested link a program of the same name as the source > file. Do you have multiple source files? You only have to edit the one > line and run "make". > > program: several.o object.o files.o > ${CLINKER} -o $@ $^ ${PETSC_LIB} > > include ${PETSC_DIR}/conf/variables > include ${PETSC_DIR}/conf/rules > Email had 1 attachment: > + Attachment2 > 1k (application/pgp-signature)
~/dev/test/petsc $ cat makefile myexample: myexample.o solver.o ${CLINKER} -o $@ $^ ${PETSC_LIB} include ${PETSC_DIR}/conf/variables include ${PETSC_DIR}/conf/rules ~/dev/test/petsc $ cat solver.f subroutine solver() #include <finclude/petscsys.h> PetscErrorCode ierr print *, "Entered petsc." ! Init PETSc call PetscInitialize(PETSC_NULL_CHARACTER,ierr) CHKERRQ(ierr) print *, "Init done." ! Finalise PETSc call PetscFinalize(ierr) CHKERRQ(ierr) print *, "Finalized." end ~/dev/test/petsc $ make gfortran -c -fPIC -Wall -Wno-unused-variable -g -fopenmp -o solver.o solver.f Warning: solver.f:2: Illegal preprocessor directive solver.f:3.12: PetscErrorCode ierr 1 Error: Unclassifiable statement at (1) solver.f:8.14: CHKERRQ(ierr) 1 Error: Unclassifiable statement at (1) solver.f:13.14: CHKERRQ(ierr) 1 Error: Unclassifiable statement at (1) make: [solver.o] Error 1 (ignored) gcc -fopenmp -fopenmp -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g3 -fno-inline -O0 -fopenmp -o myexample myexample.o solver.o -Wl,-rpath,/home/<username>/petsc/linux-amd64/lib -L/home/<username>/petsc/linux-amd64/lib -lpetsc -Wl,-rpath,/home/<username>/petsc/linux-amd64/lib -lflapack -lfblas -lX11 -lpthread -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -lgfortran -lm -lm -lstdc++ -lstdc++ -ldl -lgcc_s -ldl gcc: solver.o: No such file or directory make: *** [myexample] Error 1 ~/dev/test/petsc $