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

Error running 'MAKE' for c++ demos

0 votes

Hi,
I am following the procedure given at this link to run c++ demos.

http://fenicsproject.org/documentation/dolfin/dev/cpp/demo/index.html

I am getting the following error whenever I try to run 'make' to create the demo file. Can anyone pls. drop a clue on what it wants.

root@Jarvis:~# make
[ 50%] Building CXX object CMakeFiles/demo_poisson.dir/main.cpp.o
/home/page/Poisson/main.cpp: In function ‘int main()’:
/home/page/Poisson/main.cpp:85:7: error: no match for ‘operator=’ (operand types are ‘dolfin::CoefficientAssigner’ and ‘std::shared_ptr<Source>’)
   L.f = f;
       ^
/home/page/Poisson/main.cpp:85:7: note: candidate is:
In file included from /home/page/Poisson/Poisson.h:1863:0,
                 from /home/page/Poisson/main.cpp:35:
/usr/include/dolfin/function/CoefficientAssigner.h:52:10: note: void dolfin::CoefficientAssigner::operator=(const dolfin::GenericFunction&)
     void operator= (const GenericFunction& coefficient);
          ^
/usr/include/dolfin/function/CoefficientAssigner.h:52:10: note:   no known conversion for argument 1 from ‘std::shared_ptr<Source>’ to ‘const dolfin::GenericFunction&’
/home/page/Poisson/main.cpp:86:7: error: no match for ‘operator=’ (operand types are ‘dolfin::CoefficientAssigner’ and ‘std::shared_ptr<dUdN>’)
   L.g = g;
       ^
/home/page/Poisson/main.cpp:86:7: note: candidate is:
In file included from /home/page/Poisson/Poisson.h:1863:0,
                 from /home/page/Poisson/main.cpp:35:
/usr/include/dolfin/function/CoefficientAssigner.h:52:10: note: void dolfin::CoefficientAssigner::operator=(const dolfin::GenericFunction&)
     void operator= (const GenericFunction& coefficient);
          ^
/usr/include/dolfin/function/CoefficientAssigner.h:52:10: note:   no known conversion for argument 1 from ‘std::shared_ptr<dUdN>’ to ‘const dolfin::GenericFunction&’
make[2]: *** [CMakeFiles/demo_poisson.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/demo_poisson.dir/all] Error 2
make: *** [all] Error 2
asked May 9, 2016 by Chaitanya_Raj_Goyal FEniCS User (4,150 points)

1 Answer

+1 vote
 
Best answer

Hi,
in the main.cpp code f and g are shared_pointer-s and you need to initialize L.f and L.g with Expression objects (or GenericFunction-s depending the context ). To do this you need to specify the object (or value) pointed by the pointer (see here for references).

The solution:
Use the next pair of lines

L.f = *f;
L.g = *g;

instead of

L.f = f;
L.g = g;

Regards!

answered May 9, 2016 by hernan_mella FEniCS Expert (19,460 points)
edited May 10, 2016 by hernan_mella

Thank a lot Hernan!

I tried doing the same for all parameters and functions in undocumented elastodynamics c++ demo and got rid of the make error there too but then when I ran the demo file, it got stuck on

*** Error: Unable to read data from XML file.
*** Reason: Unable to open file "../dolfin_fine.xml.gz".
*** Where: This error was encountered inside XMLFile.cpp.

I don't know what it is. Trying to analyse and debug it. Thanks a lot though!

Maybe the path to the mesh is incorrect (?). Verify if the mesh is encountered in the correct folder or change the path in the line of the code where the mesh is loaded.

Yeah. There were 2-3 main.cpp files open in gedit. I was looking at the Poisson main.cpp and wondering where is this mesh coming from. Haha. Thanks a lot for your help.

...