<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><a href="https://petsc.org/release/docs/manual/getting_started/?highlight=user%20makefile" class="">https://petsc.org/release/docs/manual/getting_started/?highlight=user%20makefile</a><div class=""><br class=""></div><div class="">Search for <span style="color: rgba(var(--pst-color-h2),1); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: var(--pst-font-size-h2);" class="">Writing Application Codes with PETSc</span></div><div class=""><font face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" class=""><br class=""></font></div><div class=""><font face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" class="">Perhaps this needs to clearer or have links to it from the FAQ.</font></div><div class=""><font face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" class=""><br class=""></font><div class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2022, at 9:38 PM, Mark Adams <mfadams@lbl.gov> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I am finding it pretty hard to find an example of a makefile target to build an app with PETSc. <div class=""><br class=""></div><div class="">I can not find it on the docs page.</div><div class=""><br class=""></div><div class="">With Google:<br class=""><div class=""><br class=""></div><div class="">Victor has a little example that looks fine ($PETSC_LIB). (sort of, see below)<div class=""><br class=""></div><div class="">Another one is bigger and has this at the end:</div><div class=""><br class=""></div><div class="">    -${CLINKER} $< -o bin.x $(OBJ_FILES) ${PETSC_KSP_LIB} -I$(PETSC_DIR)/include<br class=""></div><div class=""><br class=""></div><div class="">I recall using PETSC_KSP_LIB the last time I wrote a makefile 20 years ago.</div></div></div><div class=""><br class=""></div><div class="">Maybe there should be a FAQ that a search would find like "Example of user makefile" with something like Victor's (dropping v2 and updating it, this looks wrong):</div><div class=""><br class=""></div><div class=""><i class="">PETSc linking<br class=""><br class="">The easiest way to link PETSc to your code is to have this line in your makefile:<br class=""><br class="">include ${PETSC_DIR}/conf/base<br class=""><br class="">This will automatically give you the compilation rules. For linking you then do:<br class=""><br class="">${CLINKER} -o ex1 ex1.o ${PETSC_LIB}<br class=""><br class="">(or FLINKER for fortran)<br class=""><br class="">You can also use this include line:<br class=""><br class="">include ${PETSC_DIR}/conf/variables<br class=""><br class="">and then you have to give the compile rules yourself. In this case, do<br class="">something like<br class=""><br class="">${CC} -c ex1.c ${PETSC_INCLUDE}<br class=""><br class="">to compile. (This is for petsc version 3, for version 2 use<br class=""><br class="">include ${PETSC_DIR}/bmake/common/base<br class=""><br class="">and replace base by variables to omit petsc’s make rules.)<br class=""><br class="">If you insist on having all the libraries and includes explicitly, use<br class=""><br class="">make getlinklibs<br class="">make getincludedirs<br class=""></i></div><div class=""><i class=""><br class=""></i></div><div class=""><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>