This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Simple mesh with mshr and c++, weird error ?

0 votes

Hello everyone,

I am new to Fenics and I want to create a polygonal mesh with a hole in it.

I have written

// Create mesh and function space
    //UnitSquareMesh mesh(32, 32);
    // Vector of points
    std::vector<Point> pts;
    pts.push_back(Point(  0.0,   0.0));
    pts.push_back(Point(  4.0,   0.0));
    pts.push_back(Point(  4.0,   8.0));
    pts.push_back(Point(  0.0,   8.0));
    pts.push_back(Point(  0.0,   8.0 / 2 + 0.5));
    pts.push_back(Point(  1.0,   8.0 / 2 + 0.5));
    pts.push_back(Point(  2.0,   8.0 / 4      ));
    pts.push_back(Point(  1.0,   8.0 / 2 - 0.5));
    pts.push_back(Point(  0.0,   8.0 / 2 - 0.5));

    // Polygone
    mshr::Polygon polyline(pts);

    // Hole
    mshr::Circle circle(Point(2.0, 7.0), 0.3);

    // Difference: IT IS A SHARED POINTER
    auto difference = polyline - circle;

    // Create a simple mesh
    Mesh mesh;

    mshr::CSGCGALMeshGenerator2D generator;

    // Mesh it!
    generator.generate(*difference, mesh);

But I keep getting following error :

Scanning dependencies of target demo_poisson [ 50%] Building CXX
object CMakeFiles/demo_poisson.dir/main.cpp.o [100%] Linking CXX
executable demo_poisson CMakeFiles/demo_poisson.dir/main.cpp.o: In
function mshr::CSGDifference::~CSGDifference()': /home/fenics/local/include/mshr/CSGOperators.h:67: undefined reference tovtable for mshr::CSGDifference'
CMakeFiles/demo_poisson.dir/main.cpp.o: In function
mshr::CSGOperator::~CSGOperator()': /home/fenics/local/include/mshr/CSGOperators.h:33: undefined reference tomshr::CSGGeometry::~CSGGeometry()'
CMakeFiles/demo_poisson.dir/main.cpp.o: In function
`mshr::CSGDifference::~CSGDifference()': ....

:_(

Anyone knows what is going on here ? Any help is appreciated, thanks in advance.

asked Mar 23, 2017 by noname FEniCS Novice (130 points)

1 Answer

0 votes

You probably have several different mshr packages on your system and the compilation process gets into trouble as these different packages get mixed up during the compilation.

answered Mar 29, 2017 by Kent-Andre Mardal FEniCS Expert (14,380 points)
...