mshr geometry generation in C++, linkage


48
views
0
6 weeks ago by
I am trying to create mesh geometries from simple shapes.  Examples in C++ are almost non-existent, so I am trying to translate to C++, e.g., section 4.5 "Generating meshes with subdomains" from the Fenics tutorial, and simple calls like:
auto cylinder = std::make_shared<Circle>(Point(0., 0.), 1.0) - std::make_shared<Circle>(Point(0., 0.), 0.5);

will compile with:
#include <mshr.h>
using namespace mshr;

However, this example shows that the library for mshr is not linked.  Here is the error on compiling:
fenics@baefb9cf7620:~/shared/build$ make
Scanning dependencies of target cfluid
[ 50%] Building CXX object CMakeFiles/cfluid.dir/main.cpp.o
[100%] Linking CXX executable cfluid
CMakeFiles/cfluid.dir/main.cpp.o: In function `mshr::CSGDifference::~CSGDifference()':
/usr/local/include/mshr/CSGOperators.h:70: undefined reference to `vtable for mshr::CSGDifference'
CMakeFiles/cfluid.dir/main.cpp.o: In function `mshr::CSGOperator::~CSGOperator()':
/usr/local/include/mshr/CSGOperators.h:33: undefined reference to `mshr::CSGGeometry::~CSGGeometry()'
CMakeFiles/cfluid.dir/main.cpp.o: In function `mshr::CSGDifference::~CSGDifference()':
/usr/local/include/mshr/CSGOperators.h:70: undefined reference to `vtable for mshr::CSGDifference'
CMakeFiles/cfluid.dir/main.cpp.o: In function `mshr::CSGOperator::~CSGOperator()':
/usr/local/include/mshr/CSGOperators.h:33: undefined reference to `mshr::CSGGeometry::~CSGGeometry()'
CMakeFiles/cfluid.dir/main.cpp.o: In function `mshr::operator-(std::shared_ptr<mshr::CSGGeometry>, std::shared_ptr<mshr::CSGGeometry>)':
/usr/local/include/mshr/CSGOperators.h:254: undefined reference to `mshr::CSGDifference::CSGDifference(std::shared_ptr<mshr::CSGGeometry>, std::shared_ptr<mshr::CSGGeometry>)'
CMakeFiles/cfluid.dir/main.cpp.o: In function `void __gnu_cxx::new_allocator<mshr::Circle>::construct<mshr::Circle, dolfin::Point, double>(mshr::Circle*, dolfin::Point&&, double&&)':
/usr/include/c++/5/ext/new_allocator.h:120: undefined reference to `mshr::Circle::Circle(dolfin::Point, double, unsigned long)'
CMakeFiles/cfluid.dir/main.cpp.o:(.rodata._ZTIN4mshr11CSGOperatorE[_ZTIN4mshr11CSGOperatorE]+0x10): undefined reference to `typeinfo for mshr::CSGGeometry'
CMakeFiles/cfluid.dir/main.cpp.o:(.rodata._ZTVN4mshr11CSGOperatorE[_ZTVN4mshr11CSGOperatorE]+0x40): undefined reference to `mshr::CSGGeometry::inside(dolfin::Point, dolfin::Point) const'
collect2: error: ld returned 1 exit status
CMakeFiles/cfluid.dir/build.make:108: recipe for target 'cfluid' failed
make[2]: *** [cfluid] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/cfluid.dir/all' failed
make[1]: *** [CMakeFiles/cfluid.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Could some please advise how to modify the CMakeLists.txt file to properly link mshr?  I am using dolfin_version(): 2017.2.0 on a Docker image.
Cheers,
--JW
Community: FEniCS Project

1 Answer


2
6 weeks ago by
Fortunately, taking a stab at it, the answer is easy.  We modify this line in CMakeLists.txt to include 'mshr':
target_link_libraries(${PROJECT_NAME} dolfin mshr)
Please login to add an answer/comment or follow this question.

Similar posts:
Search »