Hello,
I am teaching myself instant, and am not able to compile using either dolfin::compile_extension_module()
or instant::build_module()
using version 2017.1.0.
my minimal example :
from fenics import *
import instant
import os
# open the cpp code for evaluating the basis functions :
cpp_src_dir = os.path.dirname(os.path.abspath(__file__)) + "/"
header_file = open(cpp_src_dir + "test.h", "r")
code = header_file.read()
header_file.close()
system_headers = ['numpy/arrayobject.h',
'dolfin/geometry/BoundingBoxTree.h',
'dolfin/function/FunctionSpace.h']
swigargs = ['-c++', '-fcompact', '-fopenmp', '-O', '-I.', '-small']
cmake_packages = ['DOLFIN']
sources = ["test.cpp"]
source_dir = cpp_src_dir
include_dirs = [".", cpp_src_dir]
module_name = "test"
additional_decl = """
%init%{
import_array();
%}
// Include global SWIG interface files:
// Typemaps, shared_ptr declarations, exceptions, version
%include <boost_shared_ptr.i>
// Global typemaps and forward declarations
%include "dolfin/swig/typemaps/includes.i"
%include "dolfin/swig/forwarddeclarations.i"
// Global exceptions
%include <exception.i>
// Local shared_ptr declarations
%shared_ptr(dolfin::Function)
%shared_ptr(dolfin::FunctionSpace)
// %import types from submodule function of SWIG module function
%import(module="dolfin.cpp.function") "dolfin/function/Function.h"
%import(module="dolfin.cpp.function") "dolfin/function/FunctionSpace.h"
%feature("autodoc", "1");
"""
compiled_module = instant.build_module(
modulename = module_name,
code=code,
source_directory=source_dir,
additional_declarations=additional_decl,
system_headers=system_headers,
include_dirs=include_dirs,
swigargs=swigargs,
sources=sources,
cmake_packages=cmake_packages)
# compile this with Instant JIT compiler :
#inst_params = {'code' : code,
# 'module_name' : module_name,
# 'source_directory' : cpp_src_dir,
# 'sources' : sources,
# 'additional_system_headers' : ["petscsys.h"],
# 'include_dirs' : include_dirs}
#compiled_module = compile_extension_module(**inst_params)
with test.h
#ifndef __test_H
#define __test_H
#include <dolfin/function/FunctionSpace.h>
#include <dolfin/geometry/BoundingBoxTree.h>
namespace dolfin
{
class MPMModel
{
public:
MPMModel(const FunctionSpace& V);
void eval(const Array<double>& x);
private:
const FunctionSpace* Q;
std::shared_ptr<const FiniteElement> element;
std::unique_ptr<Cell> cell;
unsigned int cell_id;
std::size_t gdim;
std::size_t sdim;
std::shared_ptr<const dolfin::Mesh> mesh;
};
}
#endif
and test.cpp
#include "test.h"
using namespace dolfin;
test::test(const FunctionSpace& V)
{
Q = &V;
mesh = V.mesh();
element = V.element();
gdim = mesh->geometry().dim();
sdim = element->space_dimension();
}
void MPMModel::eval(const Array<double>& x)
{
const Point x_pt(gdim, x.data());
cell_id = mesh->bounding_box_tree()->compute_first_entity_collision(x_pt);
return cell_id;
}
I get the error :
make[2]: Leaving directory '/home/pf4d/crap/test'
make -f CMakeFiles/source_file_lib.dir/build.make CMakeFiles/source_file_lib.dir/build
make[2]: Entering directory '/home/pf4d/crap/test'
[ 20%] Building CXX object CMakeFiles/source_file_lib.dir/test.cpp.o
/usr/bin/c++ -DDOLFIN_LA_INDEX_SIZE=4 -DDOLFIN_SIZE_T=8 -DDOLFIN_VERSION=\"2017.1.0\" -DHAS_CHOLMOD -DHAS_HDF5 -DHAS_MPI -DHAS_OPENMP -DHAS_PETSC -DHAS_PETSC4PY -DHAS_SCOTCH -DHAS_SLEPC -DHAS_SLEPC4PY -DHAS_UMFPACK -DHAS_VTK -DHAS_ZLIB -DNDEBUG -DNPY_NO_DEPRECATED_API=NPY_1_11_API_VERSION -DNUMPY_VERSION_MAJOR=1 -DNUMPY_VERSION_MICRO=0 -DNUMPY_VERSION_MINOR=11 -D_FORTIFY_SOURCE=2 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DvtkFiltersFlowPaths_AUTOINIT="1(vtkFiltersParallelFlowPaths)" -DvtkIOExodus_AUTOINIT="1(vtkIOParallelExodus)" -DvtkIOGeometry_AUTOINIT="1(vtkIOMPIParallel)" -DvtkIOImage_AUTOINIT="1(vtkIOMPIImage)" -DvtkIOSQL_AUTOINIT="2(vtkIOMySQL,vtkIOPostgreSQL)" -DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL)" -DvtkRenderingCore_AUTOINIT="4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)" -DvtkRenderingFreeType_AUTOINIT="2(vtkRenderingFreeTypeFontConfig,vtkRenderingMatplotlib)" -DvtkRenderingLIC_AUTOINIT="1(vtkRenderingParallelLIC)" -DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)" -isystem /usr/include/vtk-6.2 -isystem /usr/include/freetype2 -isystem /usr/include/x86_64-linux-gnu/freetype2 -I/usr/include/jsoncpp -isystem /usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent -isystem /usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include -isystem /usr/lib/openmpi/include -isystem /usr/lib/openmpi/include/openmpi -I/usr/include/python2.7 -isystem /usr/include/x86_64-linux-gnu -I/usr/include/hdf5/serial -I/usr/include/libxml2 -I/usr/include/tcl -isystem /usr/lib/python2.7/dist-packages/ffc/backends/ufc -isystem /usr/include/suitesparse -isystem /usr/include/scotch -isystem /usr/include/eigen3 -isystem /usr/include/hdf5/openmpi -I/home/pf4d/crap/test/. -I/home/pf4d/crap -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/lib/python2.7/dist-packages/petsc4py/include -I/usr/lib/python2.7/dist-packages/slepc4py/include -I/home/pf4d/crap/test -fpermissive -fopenmp -O2 -fpic -std=c++11 -o CMakeFiles/source_file_lib.dir/test.cpp.o -c /home/pf4d/crap/test/test.cpp
In file included from /usr/include/dolfin/fem/FiniteElement.h:25:0,
from /usr/include/dolfin/function/FunctionSpace.h:37,
from /home/pf4d/crap/test.h:4,
from /home/pf4d/crap/test/test.cpp:1:
/usr/include/dolfin/common/types.h:24:22: fatal error: petscsys.h: No such file or directory
compilation terminated.
CMakeFiles/source_file_lib.dir/build.make:62: recipe for target 'CMakeFiles/source_file_lib.dir/test.cpp.o' failed
make[2]: *** [CMakeFiles/source_file_lib.dir/test.cpp.o] Error 1
make[2]: Leaving directory '/home/pf4d/crap/test'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/source_file_lib.dir/all' failed
make[1]: *** [CMakeFiles/source_file_lib.dir/all] Error 2
make[1]: Leaving directory '/home/pf4d/crap/test'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
What is strange is that yesterday I got this error, and I reinstalled fenics from the ppa and it suddenly worked. Now the problem is back and reinstalling does not fix.
Anyone?