Problem in linking problem with petsc library

  c++, compilation, petsc

I am trying to compile a code from github (https://github.com/whguan/kifmm3d).

The makefile is as:

# ----------------------------machine dependent file
#MODE = optim
MODE = debug

ifeq ($(MODE),debug)    
    BOPT = g_c++
else
    BOPT = O_c++
endif
include ${PETSC_DIR}/bmake/common/variables

# shell
SHELL = /bin/tcsh

INCLUDES = ${PETSC_INCLUDE} -I..

LIBS = -Wl,-rpath,${PETSC_DIR}/lib/lib${BOPT}/${PETSC_ARCH} ${PETSC_LIB} 
    -lfftw3 -llapack -lblas -L/usr/local/mpich-1.2.7/lib -lmpich -lstdc++

AR = ar
ARFLAGS = -r

CC  = gcc
CXX = g++

PETSC_CFLAGS    =  -DPETSC_HAVE_X11 -DPETSC_USE_DEBUG -DPETSC_USE_LOG -DPETSC_USE_STACK
PETSC_CXXFLAGS  =  -DPETSC_HAVE_X11 -DPETSC_USE_DEBUG -DPETSC_USE_LOG -DPETSC_USE_STACK
ifeq ($(MODE),debug)
    PETSC_CFLAGS    += -DPETSC_USE_BOPT_g
    PETSC_CXXFLAGS  += -DPETSC_USE_BOPT_g
else
    PETSC_CFLAGS    += -DPETSC_USE_BOPT_O
    PETSC_CXXFLAGS  += -DPETSC_USE_BOPT_O   
endif

# -Wall -Wno-sign-compare 
CFLAGS   = -fPIC -g -W -Wno-sign-compare -Wno-unused-label -MMD -DEBI_${PETSC_ARCH} $(PETSC_CFLAGS)   ${INCLUDES}
CXXFLAGS = -fPIC -g -W -Wno-sign-compare -Wno-unused-label -MMD -DEBI_${PETSC_ARCH} $(PETSC_CXXFLAGS) ${INCLUDES}
ifeq ($(MODE),debug)
else
    CFLAGS  += -O -DNDEBUG
    CXXFLAGS += -O -DNDEBUG
endif

LDFLAGS = ${LIBS}

RANLIB = ranlib

# rules
%.o: %.cpp
    $(CXX) $(CXXFLAGS) -c $*.cpp

#------------------------------------------------------
tilde:
    rm -f *~

clean:
    rm -rf *~ *.d *.o *.out *.a tt tt0 tt1
    
tags:
    etags *.hpp *.cpp

But in my installation of petsc I could not find any directory named as ‘/bmake/common/variables’, so I replaced:

include ${PETSC_DIR}/bmake/common/variables

to

include ${PETSC_DIR}/lib/petsc/conf/variables

and also added the following lines before the above include:

PETSC_DIR=/home/bidesh/petsc
PETSC_INCLUDE=${PETSC_DIR}/include

During the installation process the following error appears:

g++ -fPIC -g -W -Wno-sign-compare -Wno-unused-label -MMD -DEBI_arch-linux-c-debug -DPETSC_HAVE_X11 -DPETSC_USE_DEBUG -DPETSC_USE_LOG -DPETSC_USE_STACK -DPETSC_USE_BOPT_g /home/bidesh/petsc/include -I.. -c kernel3d_mpi.cpp
<command-line>:0:9: warning: ISO C++11 requires whitespace after the macro name
In file included from comobject_mpi.hpp:22:0,
                 from kernel3d_mpi.cpp:20:
petscsnes.h:6:10: fatal error: petscksp.h: No such file or directory
 #include <petscksp.h>
          ^~~~~~~~~~~~
compilation terminated.
../makefile.mpi:57: recipe for target 'kernel3d_mpi.o' failed
make: *** [kernel3d_mpi.o] Error 1

I tried to follow the instruction given on the website (https://pages.tacc.utexas.edu/~eijkhout/taccnotes/petsclinking/petsclinking.html), but still, the same error appears.

I am from mechanical background, not very proficient with coding and linux. I will be grateful if someone can explain the reason and how to solve this problem in simple terminology.

Thank you for your time.

Source: Windows Questions C++

LEAVE A COMMENT