[petsc-users] How to add additional cpp flags in the makefile while compiling a code?

Qiyue Lu qiyuelu1 at gmail.com
Tue Jul 9 16:38:46 CDT 2024


Hello,
I am trying to compile a *.cpp code under PETSc environment. An additional
flag is needed to link the metis partition library.
##############
# This line is necessary for linking, remember need this flag in both
compiler options and linking options
LDFLAGS= -fopenmp -lpmix -lmetis

# This line is required for using some 'helper' function like
cudaErrorCheck from samples suite
CXXFLAGS +=
-Wl,-rpath,/sw/spack/deltas11-2023-03/apps/linux-rhel8-zen/gcc-8.5.0/metis-5.1.0-v5iddu2/lib
# This two lines are required for using PETSc
include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules
##############

However, adding "CXXFLAGS += -Wl,-rpath, path_to_lib" in the makefile under
the same directory, is not working. And CPPFLAGS and CXXPPFLAGS won't work
either. No errors while compiling, but cannot find the metis.o while
running the binary. Another confusing point is, in the compilation flash
screen, LDFLAGS options can be found, but CXXFLAGS cannot.

Could you please inform me how to add additional flags in the makefile?

Thanks,
Qiyue Lu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240709/bced62f9/attachment.html>


More information about the petsc-users mailing list