[petsc-users] Having some trouble creating a library

Barry Smith bsmith at petsc.dev
Fri Sep 15 23:07:47 CDT 2023


   There are multiple ways to do this.  See https://petsc.org/release/manual/getting_started/#sec-writing-application-codes in particular

Select an application build process. The PETSC_DIR (and PETSC_ARCH if the --prefix=directoryname option was not used when configuring PETSc) environmental variable(s) must be set for any of these approaches.
make (recommended). Copy $PETSC_DIR/share/petsc/Makefile.user or $PETSC_DIR/share/petsc/Makefile.basic.user to your directory, for example, cp $PETSC_DIR/share/petsc/Makefile.user makefile
Examine the comments in your makefile

Makefile.user uses the pkg-config <https://en.wikipedia.org/wiki/Pkg-config> tool and is the recommended approach.



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.




> On Sep 15, 2023, at 6:50 PM, Alberto Cattaneo <bubu.cattaneo at gmail.com> wrote:
> 
> Greetings
> 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. 
> 
> 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.
> 
> Please forgive me if this is a silly question, but makefiles have always been tricky for me.
> 
> Respectfully:
> Alberto

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230916/1827b390/attachment.html>


More information about the petsc-users mailing list