Building CXX objects fails when compiling Poisson demo

Asked by Alejandro Ortiz-Bernardin

Hi,

I installed last version of fenics using dorsal. I run the Poisson example in Python and worked ok. Then I run the C++ version and got an error with the CXX objects. I followed every step that is given in the webpage for the Poisson demo, but I got the following error:

------------------------------

[100%] Building CXX object CMakeFiles/demo_poisson.dir/main.cpp.o
/home/icam01/Software/FEniCS/src/dolfin-1.0.0/demo/pde/poisson/cpp/main.cpp: In function ‘int main()’:
/home/icam01/Software/FEniCS/src/dolfin-1.0.0/demo/pde/poisson/cpp/main.cpp:71:3: error: ‘UnitSquareMesh’ was not declared in this scope
/home/icam01/Software/FEniCS/src/dolfin-1.0.0/demo/pde/poisson/cpp/main.cpp:71:18: error: expected ‘;’ before ‘mesh’
/home/icam01/Software/FEniCS/src/dolfin-1.0.0/demo/pde/poisson/cpp/main.cpp:72:28: error: ‘mesh’ was not declared in this scope
/home/icam01/Software/FEniCS/src/dolfin-1.0.0/demo/pde/poisson/cpp/main.cpp:97:15: error: ‘interactive’ was not declared in this scope
make[2]: *** [CMakeFiles/demo_poisson.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/demo_poisson.dir/all] Error 2
make: *** [all] Error 2

-------------------

It is like the functions of the classes of the dolfin namspace are not being recognized. However, I know the headers are read correctly. So, I don't see how the function, say, UnitSquareMesh is not recognized as declared. Is there anybody that knows something about this error? Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Johannes Ring (johannr) said :
#1

UnitSquareMesh was first introduced in DOLFIN 1.1.0 but it looks like you are using DOLFIN 1.0.0. However, it is strange that you have this problem since it looks like you are using the demo that was shipped with DOLFIN 1.0.0, which should of course work fine with 1.0.0.

Could you try to build and run the demo from the installation directory instead of the source directory? You should find them under /home/icam01/Software/FEniCS/share/dolfin/demo (assuming you have installed FEniCS in /home/icam01/Software/FEniCS).

Revision history for this message
Alejandro Ortiz-Bernardin (aortizb) said :
#2

Yes, I have Dolfin 1.0.0. Not sure what you asked. But I ran the cahn-hilliard demo as an extra check and I got problems once again. However, UnitSquare appears this time. I provided the path to the directories where the headers reside. But yet the problem persists:

/home/icam01/Software/FEniCS/share/dolfin/demo/pde/cahn-hilliard/cpp/main.o||In function `main':|
main.cpp|| undefined reference to `dolfin::init(int, char**)'|
main.cpp|| undefined reference to `dolfin::UnitSquare::UnitSquare(unsigned int, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::Constant::Constant(double)'|
main.cpp|| undefined reference to `dolfin::Constant::Constant(double)'|
main.cpp|| undefined reference to `dolfin::Constant::Constant(double)'|
main.cpp|| undefined reference to `dolfin::Constant::operator double() const'|
main.cpp|| undefined reference to `dolfin::NewtonSolver::NewtonSolver(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::Parameters::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::Parameters::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::Parameters::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::Parameters::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::File::File(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::Function::operator[](unsigned int) const'|
main.cpp|| undefined reference to `dolfin::Constant::operator double() const'|
main.cpp|| undefined reference to `dolfin::Function::vector()'|
main.cpp|| undefined reference to `dolfin::Function::vector()'|
main.cpp|| undefined reference to `dolfin::Function::vector()'|
main.cpp|| undefined reference to `dolfin::NewtonSolver::solve(dolfin::NonlinearProblem&, dolfin::GenericVector&)'|
main.cpp|| undefined reference to `dolfin::Function::operator[](unsigned int) const'|
main.cpp|| undefined reference to `dolfin::Function::operator[](unsigned int) const'|
main.cpp|| undefined reference to `dolfin::plot(dolfin::Function const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
main.cpp|| undefined reference to `dolfin::File::~File()'|
main.cpp|| undefined reference to `dolfin::NewtonSolver::~NewtonSolver()'|
main.cpp|| undefined reference to `dolfin::Constant::~Constant()'|
main.cpp|| undefined reference to `dolfin::Constant::~Constant()'|
main.cpp|| undefined reference to `dolfin::Constant::~Constant()'|
main.cpp|| undefined reference to `dolfin::NewtonSolver::~NewtonSolver()'|
main.cpp|| undefined reference to `dolfin::NewtonSolver::~NewtonSolver()'|
main.cpp|| undefined reference to `dolfin::File::~File()'|
main.cpp|| undefined reference to `dolfin::File::~File()'|
main.cpp|| undefined reference to `dolfin::File::~File()'|
main.cpp|| undefined reference to `dolfin::NewtonSolver::~NewtonSolver()'|
main.cpp|| undefined reference to `dolfin::Constant::~Constant()'|
main.cpp|| undefined reference to `dolfin::Constant::~Constant()'|
main.cpp|| undefined reference to `dolfin::Constant::~Constant()'|
/home/icam01/Software/FEniCS/share/dolfin/demo/pde/cahn-hilliard/cpp/main.o||In function `CahnHilliard2D::Form_0_FunctionSpace_0::Form_0_FunctionSpace_0(dolfin::Mesh const&)':|
main.cpp:(.text._ZN14CahnHilliard2D22Form_0_FunctionSpace_0C2ERKN6dolfin4MeshE[_ZN14CahnHilliard2D22Form_0_FunctionSpace_0C5ERKN6dolfin4MeshE]+0x32)||undefined reference to `cahnhilliard2d_dofmap_2::cahnhilliard2d_dofmap_2()'|
main.cpp:(.text._ZN14CahnHilliard2D22Form_0_FunctionSpace_0C2ERKN6dolfin4MeshE[_ZN14CahnHilliard2D22Form_0_FunctionSpace_0C5ERKN6dolfin4MeshE]+0x8d)||undefined reference to `dolfin::DofMap::DofMap(boost::shared_ptr<ufc::dofmap const>, dolfin::Mesh const&)'|
main.cpp:(.text._ZN14CahnHilliard2D22Form_0_FunctionSpace_0C2ERKN6dolfin4MeshE[_ZN14CahnHilliard2D22Form_0_FunctionSpace_0C5ERKN6dolfin4MeshE]+0xd4)||undefined reference to `cahnhilliard2d_finite_element_2::cahnhilliard2d_finite_element_2()'|
main.cpp:(.text._ZN14CahnHilliard2D22Form_0_FunctionSpace_0C2ERKN6dolfin4MeshE[_ZN14CahnHilliard2D22Form_0_FunctionSpace_0C5ERKN6dolfin4MeshE]+0x11c)||undefined reference to `dolfin::FiniteElement::FiniteElement(boost::shared_ptr<ufc::finite_element const>)'|
main.cpp:(.text._ZN14CahnHilliard2D22Form_0_FunctionSpace_0C2ERKN6dolfin4MeshE[_ZN14CahnHilliard2D22Form_0_FunctionSpace_0C5ERKN6dolfin4MeshE]+0x15f)||undefined reference to `dolfin::FunctionSpace::FunctionSpace(boost::shared_ptr<dolfin::Mesh const>, boost::shared_ptr<dolfin::FiniteElement const>, boost::shared_ptr<dolfin::GenericDofMap const>)'|
/home/icam01/Software/FEniCS/share/dolfin/demo/pde/cahn-hilliard/cpp/main.o||In function `CahnHilliard2D::Form_0_FunctionSpace_0::~Form_0_FunctionSpace_0()':|
main.cpp:(.text._ZN14CahnHilliard2D22Form_0_FunctionSpace_0D2Ev[_ZN14CahnHilliard2D22Form_0_FunctionSpace_0D5Ev]+0x1f)||undefined reference to `dolfin::FunctionSpace::~FunctionSpace()'|
/home/icam01/Software/FEniCS/share/dolfin/demo/pde/cahn-hilliard/cpp/main.o||In function `CahnHilliard2D::Form_0::Form_0(boost::shared_ptr<dolfin::FunctionSpace const>)':|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x25)||undefined reference to `dolfin::Form::Form(unsigned int, unsigned int)'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x4f)||undefined reference to `dolfin::CoefficientAssigner::CoefficientAssigner(dolfin::Form&, unsigned int)'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x6e)||undefined reference to `dolfin::CoefficientAssigner::CoefficientAssigner(dolfin::Form&, unsigned int)'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x8d)||undefined reference to `dolfin::CoefficientAssigner::CoefficientAssigner(dolfin::Form&, unsigned int)'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0xac)||undefined reference to `dolfin::CoefficientAssigner::CoefficientAssigner(dolfin::Form&, unsigned int)'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0xcb)||undefined reference to `dolfin::CoefficientAssigner::CoefficientAssigner(dolfin::Form&, unsigned int)'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x107)||undefined reference to `cahnhilliard2d_form_0::cahnhilliard2d_form_0()'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x177)||undefined reference to `dolfin::CoefficientAssigner::~CoefficientAssigner()'|
main.cpp:(.text._ZN14CahnHilliard2D6Form_0C2EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE[_ZN14CahnHilliard2D6Form_0C5EN5boost10shared_ptrIKN6dolfin13FunctionSpaceEEE]+0x18e)||undefined reference to `dolfin::CoefficientAssigner::~CoefficientAssigner()'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|

Revision history for this message
Johannes Ring (johannr) said :
#3

I'm not sure, but it looks like you might be mixing different versions of DOLFIN. Maybe it would be better if you upgraded to DOLFIN 1.1.0 (if you don't need 1.0.0 for some reason). You will need the development version of Dorsal to build version 1.1.0. You can get this by running

  bzr branch lp:dorsal

Can you help with this problem?

Provide an answer of your own, or ask Alejandro Ortiz-Bernardin for more information if necessary.

To post a message you must log in.