[petsc-users] C++ Makefile for PETSc program
Justin Dong
justin_dong at brown.edu
Wed Aug 29 11:09:55 CDT 2018
Hi all,
I have a program with C++ that I am trying to integrate with PETSc on MacOS
X. My Makefile looks like this
#-----[Makefile]------
> include ${PETSC_DIR}/lib/petsc/conf/variables
> include ${PETSC_DIR}/lib/petsc/conf/rules
> include ${PETSC_DIR}/lib/petsc/conf/test
>
> #----[Directories]----
> oPath = obj
> sPath = src
> iPath = inc $(PETSC_LIB)
> #====================
>
> #---[Compiler and Settings]-----
> compiler = g++-8
> compilerFlags = -std=c++11 -Wall -lm -llapack -lblas -O3
> paths = -I./$(iPath)
> #======================
>
> #----[Variable Names]-------
> headers = $(wildcard $(iPath)/*.hpp)
> sources = $(wildcard $(sPath)/*.cpp)
> objects = $(subst $(sPath)/,$(oPath)/,$(sources:.cpp=.o))
> #==========================
>
> #----[Compilation]---------
> main:$(objects) $(headers) main.cpp
> $(compiler) $(compilerFlags) -o main $(objects) main.cpp $(PETSC_LIB)
> $(paths)
> $(oPath)/%.o:$(sPath)/%.cpp $(subst $(sPath)/, $(iPath)/,$(<:.cpp=.hpp))
> @mkdir -p $(@D)
> $(compiler) $(compilerFlags) -o $@ -c $(paths) $<
>
> #-----[Clean up]-------
> # clean:rm main
> # rm -rf $(oPath)/
When I try to include "petsc.h", I get a "no such file or directory" error.
I have PETSC_DIR and PETSC_ARCH set correctly, but I'm not the most
proficient with Make. Can someone provide some tips on how to get this
working properly?
Best,
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180829/2a461bc4/attachment.html>
More information about the petsc-users
mailing list