1

I try to make mathgl work, but the linker can't find the library. I installed it through the user repository from arch linux. I just copied the example program:

#include <mgl2/mgl.h>
int main()
{
  mglGraph gr;
  gr.FPlot("sin(pi*x)");
  gr.WriteFrame("test.png");
}

The official website states you need to link lmgl, but I get this error:

$ g++ main.cpp -lmgl
/usr/bin/ld: cannot find -lmgl
collect2: error: ld returned 1 exit status

I couldn't figure out where to start looking for the library. How can I see where it was installed?

I was looking for libmgl with ldconfig -p getting these results:

$ ldconfig -p | grep libmgl    
    libmgl2.so.7.5.0 (libc6,x86-64) => /usr/lib/libmgl2.so.7.5.0
    libmgl2.so (libc6,x86-64) => /usr/lib/libmgl2.so
    libmgl2-qt5.so.7.5.0 (libc6,x86-64) => /usr/lib/libmgl2-qt5.so.7.5.0
    libmgl2-qt5.so (libc6,x86-64) => /usr/lib/libmgl2-qt5.so
    libmgl2-qt.so.7.5.0 (libc6,x86-64) => /usr/lib/libmgl2-qt.so.7.5.0
    libmgl2-qt.so (libc6,x86-64) => /usr/lib/libmgl2-qt.so
    libmgl2-glut.so.7.5.0 (libc6,x86-64) => /usr/lib/libmgl2-glut.so.7.5.0
    libmgl2-glut.so (libc6,x86-64) => /usr/lib/libmgl2-glut.so
Natjo
  • 2,005
  • 29
  • 75

1 Answers1

0

As Amadeus indicated, using

$ g++ main.cpp -lmgl2

should work.

Lukas Kapp
  • 16
  • 2