无法使用mathgl编译c ++程序

Cant compile c++ program using mathgl

我已经使用

安装了 mathgl 库
sudo apt-get install mathgl

然后我从他们的 sourceforge 页面复制了以下示例程序。

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

还有

gcc test.cpp -lmgl-qt -lmgl -lm

我收到以下错误消息

test.cpp:1:21: fatal error: mgl2/qt.h: No such file or directory
 #include <mgl2/qt.h>
                     ^
compilation terminated.

现在我使用 locate 查找此头文件,但找不到。我经常遇到这个问题,所以我安装了一个库,然后花了很长时间试图让编译器知道在哪里可以找到链接器和头文件(我有点初学者),我认为必须有更好的方法或者我缺少的东西。那么我怎样才能找到我需要的文件并让编译器知道在哪里搜索呢?

您需要安装开发包:

sudo apt-get install libmgl-dev

此包包含 headers 和库,请参阅 file list