0

I have installed mathgl, using:

sudo apt-get install mathgl
sudo apt-get install libmgl-dev

When i tried to compile a sample c++ program from here

#include <mgl2/qt.h>
int sample(mglGraph *gr)
{
  gr->Rotate(60,40);
  gr->Box();
  return 0;
}
//-----------------------------------------------------
int main(int argc,char **argv)
{
  mglQT gr(sample,"MathGL examples");
  return gr.Run();
}

using gcc sample.cpp -lmgl-qt -lmgl i get compiler errors at mathgl functions.

lefteris@lefteris-ubuntu:~/Documents/C++/Numerical$ gcc sample.cpp -lmgl-qt -lmgl
In file included from /usr/include/mgl2/abstract.h:27:0,
                 from /usr/include/mgl2/qt.h:22,
                 from sample.cpp:1:
/usr/include/mgl2/type.h:42:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglPoint(mglPoint &&d):x(d.x),y(d.y),z(d.z),c(d.c) {}
                    ^
/usr/include/mgl2/type.h:42:23: error: invalid constructor; you probably meant ‘mglPoint (const mglPoint&)’
  mglPoint(mglPoint &&d):x(d.x),y(d.y),z(d.z),c(d.c) {}
                       ^
/usr/include/mgl2/type.h:117:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglColor(mglColor &&d):r(d.r),g(d.g),b(d.b),a(d.a) {}
                    ^
/usr/include/mgl2/type.h:117:23: error: invalid constructor; you probably meant ‘mglColor (const mglColor&)’
  mglColor(mglColor &&d):r(d.r),g(d.g),b(d.b),a(d.a) {}
                       ^
In file included from /usr/include/mgl2/mgl_cf.h:24:0,
                 from /usr/include/mgl2/mgl.h:23,
                 from /usr/include/mgl2/wnd.h:23,
                 from /usr/include/mgl2/qt.h:36,
                 from sample.cpp:1:
/usr/include/mgl2/data.h:49:18: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglData(mglData &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
                  ^
/usr/include/mgl2/data.h:49:21: error: invalid constructor; you probably meant ‘mglData (const mglData&)’
  mglData(mglData &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
                     ^
/usr/include/mgl2/data.h:570:18: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglExpr(mglExpr &&d):ex(d.ex) { d.ex=0; }
                  ^
/usr/include/mgl2/data.h:570:21: error: invalid constructor; you probably meant ‘mglExpr (const mglExpr&)’
  mglExpr(mglExpr &&d):ex(d.ex) { d.ex=0; }
                     ^
/usr/include/mgl2/data.h:601:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglDataV(mglDataV &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk),a0(d.a0)
                    ^
/usr/include/mgl2/data.h:601:23: error: invalid constructor; you probably meant ‘mglDataV (const mglDataV&)’
  mglDataV(mglDataV &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk),a0(d.a0)
                       ^
/usr/include/mgl2/data.h:667:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglDataW(mglDataW &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk)
                    ^
/usr/include/mgl2/data.h:667:23: error: invalid constructor; you probably meant ‘mglDataW (const mglDataW&)’
  mglDataW(mglDataW &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk)
                       ^
/usr/include/mgl2/data.h:741:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglDataF(mglDataF &&d):nx(d.nx),ny(d.ny),nz(d.nz), str(d.str), v1(d.v1),v2(d.v2), ex(d.ex), dx(d.dx),dy(d.dy),dz(d.dz), dfunc(d.dfunc),par(d.par)
                    ^
/usr/include/mgl2/data.h:741:23: error: invalid constructor; you probably meant ‘mglDataF (const mglDataF&)’
  mglDataF(mglDataF &&d):nx(d.nx),ny(d.ny),nz(d.nz), str(d.str), v1(d.v1),v2(d.v2), ex(d.ex), dx(d.dx),dy(d.dy),dz(d.dz), dfunc(d.dfunc),par(d.par)
                       ^
/usr/include/mgl2/data.h:846:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglDataT(mglDataT &&d):dat(d.dat),ind(d.ind)
                    ^
/usr/include/mgl2/data.h:846:23: error: invalid constructor; you probably meant ‘mglDataT (const mglDataT&)’
  mglDataT(mglDataT &&d):dat(d.dat),ind(d.ind)
                       ^
/usr/include/mgl2/data.h:893:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglDataR(mglDataR &&d):dat(d.dat),ind(d.ind)
                    ^
/usr/include/mgl2/data.h:893:23: error: invalid constructor; you probably meant ‘mglDataR (const mglDataR&)’
  mglDataR(mglDataR &&d):dat(d.dat),ind(d.ind)
                       ^
In file included from /usr/include/mgl2/mgl_cf.h:25:0,
                 from /usr/include/mgl2/mgl.h:23,
                 from /usr/include/mgl2/wnd.h:23,
                 from /usr/include/mgl2/qt.h:36,
                 from sample.cpp:1:
/usr/include/mgl2/datac.h:50:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
  mglDataC(mglDataC &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
                    ^
/usr/include/mgl2/datac.h:50:23: error: invalid constructor; you probably meant ‘mglDataC (const mglDataC&)’
  mglDataC(mglDataC &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
                   ^

i tried running the python sample, and it worked fine. Does anyone know how to fix this problem?

Louen
  • 3,617
  • 1
  • 29
  • 49
Lefteris
  • 111
  • 2
  • 6
  • 1
    It seems that your compiler does not accept the move constructor. Try with `gcc -std=c++11` (or c++14) maybe ? – Louen Jan 26 '17 at 16:04
  • i have tried with 'gcc -std=c++11' and nothing happend. At the first chance i will try the c++14 option – Lefteris Jan 26 '17 at 16:24
  • 1
    http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc – Simon Kraemer Jan 26 '17 at 16:56
  • Thank you for you suggestions. The command that actually compiled the sample was `g++ test.cpp -lmgl-qt -lmgl -std=gnu++11`. – Lefteris Jan 26 '17 at 17:14

0 Answers0