> On Aug 29, 2018, at 11:09 AM, Justin Dong <[email protected]> wrote:
> 
> 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

  1) Unless you are using a ./configure with a --prefix install option you need 

> include ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/variables
> include ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/rules
> include ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/test

   2) Though you include these files your makefile below IGNORES the various 
compiler flags that are set in these files hence, for example, the 
-I${PETSC_DIR}/include that tells the compiler the location of the PETSc 
makefile is not used.

     You need to at a minimum add to your compilerFlags variable the various 
variables set in the included files such as CFLAGS

    Barry


>  
> #----[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

Reply via email to