[petsc-users] Makefile for mixed C++ and Fortran code

Danyang Su danyang.su at gmail.com
Fri Jun 1 12:37:21 CDT 2018


Follow up:

With following command

executable: $(SOURCES) chkopts
     -${FLINKER} $(FFLAGS) $(FPPFLAGS) $(CPPFLAGS)  -o executable.out 
$(SOURCES) ${PETSC_LIB}

%.o:%.F90
     $(FLINKER) $(FFLAGS) $(FPPFLAGS) -c -frounding-math $< -o $@
%.o:%.cpp
     $(CLINKER) $(CXXFLAGS) $(CPPFLAGS) -c -frounding-math $< -o $@

The compiler return error: no match function.

../../usg/cgal_triangulation_2d.cpp: In function ‘void 
outputTriangulation2d(in\
t, const char*, int, const char*)’:
../../usg/cgal_triangulation_2d.cpp:485:20: error: no matching function 
for cal\
l to ‘std::basic_ofstream<char>::open(std::string&)’
     out.open(strfile);

Thanks,


Danyang

On 18-06-01 10:07 AM, Danyang Su wrote:
> Hi All,
>
> My code needs to link to an external C++ library (CGAL). The code is 
> written in Fortran and I have already written interface to let Fortran 
> call C++ function. For the sequential version without PETSc, it can be 
> compiled without problem using the following makefile. The parallel 
> version without CGAL can also be compiled successfully. However, when 
> I tried to use PETSc together with CGAL library, I cannot compile the 
> code. My questions is: How can I modify the makefile? Do I need to 
> reconfigure PETSc with special flags? All the makefile samples are 
> shown below.
>
> #makefile for sequential version
>
> FC = gfortran
> #FC = ifort
> CXX = g++ -std=c++11
>
> DLIB = -lstdc++ -lm -L/usr/local/lib -rdynamic 
> /usr/local/lib/libmpfr.so /usr/local/lib/libgmp.so 
> /usr/local/lib/libCGAL_ImageIO.so.11.0.1 
> /usr/local/lib/libCGAL.so.11.0.1 /usr/local/lib/libboost_thread.so 
> /usr/local/lib/libboost_system.so -lpthread -lGLU -lGL -lX11 -lXext 
> -lz /usr/local/lib/libCGAL_ImageIO.so.11.0.1 
> /usr/local/lib/libCGAL.so.11.0.1 /usr/local/lib/libboost_thread.so 
> /usr/local/lib/libboost_system.so -lpthread -lGLU -lGL -lX11 -lXext 
> -lz /usr/local/lib/libmpfr.so /usr/local/lib/libgmp.so 
> /usr/local/lib/libboost_thread.so /usr/local/lib/libboost_system.so 
> -lpthread -Wl,-rpath,/usr/local/lib
>
> FFLAGS = -O3
> CXXFLAGS = -O3
>
> FPPFLAGS =  -DUSECGAL
>
> SRC =./../../
>
> SOURCES = $(SRC)usg/math_common.o\
>     $(SRC)usg/geometry_definition.o\
>     $(SRC)usg/cgal_common.o\
>
> ...
>
> executable: $(SOURCES)
>     $(FC) $(FFLAGS) $(FPPFLAGS) -o executable.out $(SOURCES) 
> ${LIS_LIB} $(DLIB)
> %.o:%.F90
>     $(FC) $(FFLAGS) $(FPPFLAGS) -c -frounding-math $< -o $@
> %.o:%.cpp
>     $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -frounding-math $< -o $@
>
>
> #makefile for parallel version with PETSc, without CGAL
>
> #FC = ifort
> #FC = gfortran
>
> DLIB = -lm
>
> FFLAGS = -O3
>
> FPPFLAGS =  -DUSEPETSC
>
> SRC =./../../
>
> SOURCES = $(SRC)usg/math_common.o\
>     $(SRC)usg/geometry_definition.o\
>     $(SRC)usg/cgal_common.o\
>
> ...
>
> executable: $(SOURCES) chkopts
>     -${FLINKER} $(FFLAGS) $(FPPFLAGS) $(CPPFLAGS)  -o executable.out 
> $(SOURCES) ${PETSC_LIB}
>
>
> #makefile for parallel version with PETSc, with CGAL, CANNOT work
>
> #FC = ifort
> #FC = gfortran
>
> DLIB = -lm
>
> FFLAGS = -O3
>
> FPPFLAGS =  -DUSEPETSC -DUSECGAL
>
> SRC =./../../
>
> SOURCES = $(SRC)usg/math_common.o\
>     $(SRC)usg/geometry_definition.o\
>     $(SRC)usg/cgal_common.o\
>
> ...
>
> executable: $(SOURCES) chkopts
>     -${FLINKER} $(FFLAGS) $(FPPFLAGS) $(CPPFLAGS)  -o executable.out 
> $(SOURCES) ${PETSC_LIB}
>
> %.o:%.F90
>     $(FC) $(FFLAGS) $(FPPFLAGS) -c -frounding-math $< -o $@
> %.o:%.cpp
>     $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -frounding-math $< -o $@
>
>
> Thanks,
>
> Danyang
>



More information about the petsc-users mailing list