编译 mathgl 示例 c++

Compiling mathgl sample c++

提问人:Lefteris 提问时间:1/26/2017 最后编辑:LouenLefteris 更新时间:1/27/2017 访问量:956

问:

我已经安装了mathgl,使用:

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

当我尝试从这里编译示例 c++ 程序时

#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();
}

使用 I get 编译器错误 at MathGL 函数。gcc sample.cpp -lmgl-qt -lmgl

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)
                   ^

我尝试运行 Python 示例,它工作正常。 有谁知道如何解决这个问题?

C++ Linux 数学

评论

1赞 Louen 1/27/2017
您的编译器似乎不接受移动构造函数。也许尝试使用(或 c++14)?gcc -std=c++11
0赞 Lefteris 1/27/2017
我尝试过使用“gcc -std=c++11”,但没有任何反应。第一次有机会,我会尝试 c++14 选项
1赞 Simon Kraemer 1/27/2017
stackoverflow.com/questions/172587/......
0赞 Lefteris 1/27/2017
谢谢你的建议。实际编译示例的命令是 。g++ test.cpp -lmgl-qt -lmgl -std=gnu++11

答: 暂无答案