<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> There are multiple ways to do this. See <a href="https://petsc.org/release/manual/getting_started/#sec-writing-application-codes">https://petsc.org/release/manual/getting_started/#sec-writing-application-codes</a> in particular<div><br></div><div><p style="box-sizing: border-box; margin-bottom: 0.25rem; margin-top: 0.25rem; color: rgb(100, 100, 100); font-size: 15px; caret-color: rgb(100, 100, 100); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";">Select an application build process. The <code class="docutils literal notranslate" style="box-sizing: border-box; font-family: var(--pst-font-family-monospace); font-size: 13.125px; overflow-wrap: break-word; color: var(--pst-color-inline-code); border: 1px solid var(--pst-color-on-surface); border-radius: 0.25rem; padding: 0.1rem 0.25rem;"><span class="pre" style="box-sizing: border-box; -webkit-hyphens: none; white-space: nowrap;">PETSC_DIR</span></code> (and <code class="docutils literal notranslate" style="box-sizing: border-box; font-family: var(--pst-font-family-monospace); font-size: 13.125px; overflow-wrap: break-word; color: var(--pst-color-inline-code); border: 1px solid var(--pst-color-on-surface); border-radius: 0.25rem; padding: 0.1rem 0.25rem;"><span class="pre" style="box-sizing: border-box; -webkit-hyphens: none; white-space: nowrap;">PETSC_ARCH</span></code> if the <code class="docutils literal notranslate" style="box-sizing: border-box; font-family: var(--pst-font-family-monospace); font-size: 13.125px; overflow-wrap: break-word; color: var(--pst-color-inline-code); border: 1px solid var(--pst-color-on-surface); border-radius: 0.25rem; padding: 0.1rem 0.25rem;"><span class="pre" style="box-sizing: border-box; -webkit-hyphens: none; white-space: nowrap;">--prefix=directoryname</span></code> option was not used when configuring PETSc) environmental variable(s) must be set for any of these approaches.</p><ul style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px; caret-color: rgb(100, 100, 100); color: rgb(100, 100, 100);"><li style="box-sizing: border-box;"><p style="font-size: 1em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; box-sizing: border-box; margin-bottom: 0.25rem; margin-top: 0.25rem; color: var(--pst-color-text-muted);">make (recommended). Copy $PETSC_DIR/share/petsc/Makefile.user or $PETSC_DIR/share/petsc/Makefile.basic.user to your directory, for example, <code class="docutils literal notranslate" style="box-sizing: border-box; font-family: var(--pst-font-family-monospace); font-size: 13.125px; overflow-wrap: break-word; color: var(--pst-color-inline-code); border: 1px solid var(--pst-color-on-surface); border-radius: 0.25rem; padding: 0.1rem 0.25rem;"><span class="pre" style="box-sizing: border-box; -webkit-hyphens: none; white-space: nowrap;">cp</span> <span class="pre" style="box-sizing: border-box; -webkit-hyphens: none; white-space: nowrap;">$PETSC_DIR/share/petsc/Makefile.user</span> <span class="pre" style="box-sizing: border-box; -webkit-hyphens: none; white-space: nowrap;">makefile</span></code></p><p style="font-size: 1em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; box-sizing: border-box; margin-bottom: 1.15rem; margin-top: 0px; color: var(--pst-color-text-muted);">Examine the comments in your makefile</p><p style="font-size: 1em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; box-sizing: border-box; margin-bottom: 1.15rem; margin-top: 0px; color: var(--pst-color-text-muted);">Makefile.user uses the <a class="reference external" href="https://en.wikipedia.org/wiki/Pkg-config" style="box-sizing: border-box; color: var(--pst-color-link); text-decoration: none;">pkg-config</a> tool and is the recommended approach.</p><p style="font-size: 1em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; box-sizing: border-box; margin-bottom: 1.15rem; margin-top: 0px; color: var(--pst-color-text-muted);"><br></p><p style="box-sizing: border-box; margin-bottom: 1.15rem; margin-top: 0px; color: var(--pst-color-text-muted);">These makefile automatically set certain make variables that handle setting the locations of the include files for you. The comments in the makefiles tell you how to proceed.</p><p style="font-size: 1em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; box-sizing: border-box; margin-bottom: 1.15rem; margin-top: 0px; color: var(--pst-color-text-muted);"><br></p></li></ul><div><br><blockquote type="cite"><div>On Sep 15, 2023, at 6:50 PM, Alberto Cattaneo <bubu.cattaneo@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>Greetings</div><div>I hope this email reaches you well. I'm afraid I'm having a bit of trouble using PETSC for a library I'm writing for myself, and I was hoping for some clarification/help. I've been writing PETSC C code and compiling it using the included makefiles in the tutorial section as that was sufficient. However, I decided since there are a few functions I keep using it would be beneficial to write them and make them into a little library for myself. However, I'm having some difficulty understanding what I need to include when trying to compile something as a library with PETSC stuff. The makefiles are rather complicated, so I thought it may be more prudent to just ask. <br><br></div><div>I'm trying to use #include <petscksp.h> and #include <petscmath.h> to have access to the PETSC data types (PetscScalar, PetscInt) but I can't find where those files are located, and I wanted to check if just using gcc with those added was sufficient or if I needed some other compiler flags and options.</div><div><br></div><div>Please forgive me if this is a silly question, but makefiles have always been tricky for me.</div><div><br></div><div>Respectfully:</div><div>Alberto<br></div></div>
</div></blockquote></div><br></div></body></html>