Search code examples
c++mathgl

Cant compile c++ program using mathgl


I have installed the mathgl library using

sudo apt-get install mathgl

Then from their sourceforge page I copied the following example program.

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

And the

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

I get the following error message

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

Now I looked for this header file using locate and I couldn't find it. I get this problem so often that I install a library and then spend ages trying to get the compiler to know where to find the linker and header files (I am a bit of a beginner) and I think to myself there must be a better way or something that I am missing. So how can I locate the files I need and let the compiler know where to search?


Solution

  • You need to install the developer package:

    sudo apt-get install libmgl-dev
    

    This package contains both the headers and the libraries, see the file list.