Please let me know if there is anyway I can get MathGL working on my computer. If there's any mistake in the following tests, pls kindly let me know.
Thank you.
Ok, I've been struggling this issue for quite a long time. Here's what happens when I try to visualize my results from C/Fortran code
The basic information is:
OS: Mac OSX 12.3.1
GCC/GFortran version: 11.3.0
clang version: 13.1.6
Case I: Make by default
cmake .
cmake .
make install
This looks like a minimal installation. The header files are installed to /usr/local/include and the libs are installed to /usr/local/lib. The default build is able to compile the following code if I run
**[compile default]**
g++ src/testMathGL.cpp -o testMathGL -lmgl
**[testMathGL.cpp]**
#include "mgl2/mgl.h"
int main() {
mglGraph gr;
gr.Title("MathGL Demo");
gr.SetOrigin(0, 0);
gr.SetRanges(0, 10, -2.5, 2.5);
gr.FPlot("sin(1.7*2*pi*x) + sin(1.9*2*pi*x)", "r-2");
gr.Axis();
gr.Grid();
gr.WriteFrame("mgl_example.svg");
}
I believe the default build is good enough to generate plots. However, the plot is generated and automatically saved on disk. it is not convenient if I am debugging my code(may generate lots of plots and I don't need those). Which might be, I need to tune some parameters to obtain a promising and physically realizable setup. So I want the plot generated and open directly after each single run.
Case II:
In that case, I am trying to run the following code
**[testMathGL-fltk]**
#include "mgl2/fltk.h"
int graph(mglGraph *gr) {
gr->Title("MathGL Demo");
gr->SetOrigin(0, 0);
gr->SetRanges(0, 10, -2.5, 2.5);
gr->FPlot("sin(1.7*2*pi*x) + sin(1.9*2*pi*x)", "r-4");
gr->Axis();
gr->Grid();
return 0;
}
int main() {
mglFLTK gr(graph, "MathGL demo window title");
return gr.Run();
}
If I try to compile the code with default command
**[compile default]**
g++ src/testMathGL.cpp -o testMathGL -lmgl (-lmgl-fltk)
The error is straightforward
'mgl2/fltk.h' file not found
Of course, the default build doesn't contain any graphical libraries. To include those libraries, I tried the prebuilt libraries from MathGL. And I compile as
**[compile prebuilt]**
g++ src/testMathGL.cpp -o testMathGL -I/Users/somebody/Downloads/mathgl-8.0-mingw.win64/include/ -L/Users/somebody/Downloads/mathgl-8.0-mingw.win64/lib/-lmgl (-lmgl-fltk)
But g++ keeps giving me the errors like
unknown type name 'dllimport'
As the prebuilt download always has win64 as suffix, I think for Unix-like system, I need to compile it myself. From the installation instructions from MathGL, I am told it is necessary to enable some keys when configuring the make process. see also http://mathgl.sourceforge.net/doc_en/Installation.html
cmake -D enable-all=on -D enable-all-widgets=on -D enable-all-swig=on .
Then it gives a lot of errors stating missing dependencies. I figured most of them, like Qt5, hdf5, glut, fltk, wxWidgets, swig, octave. Now there are still some missing dependencies I don't know how to resolve. As it shows
CMake Error at CMakeLists.txt:515 (message):
HDF4_LIB-NOTFOUND
CMake Error at CMakeLists.txt:516 (message):
HDF4MF_LIB-NOTFOUND
CMake Error at CMakeLists.txt:517 (message):
HDF4_INCLUDE_DIR-NOTFOUND
CMake Error at CMakeLists.txt:518 (message):
Couldn't find HDF4 libraries.
CMake Error at CMakeLists.txt:608 (message):
Couldn't find libHaru or libhpdf.
CMake Error at CMakeLists.txt:612 (message):
Couldn't find headers of 3d-enabled version of libhpdf.
-- Couldn't find Qt5 WebKitWidgets library. JSON sample disabled.
c-- /usr/local/bin/octave-config x86_64-apple-darwin21.3.0 api-v57
-- Configuring incomplete, errors occurred!
See also "/Users/somebody/Downloads/mathgl-8.0.1/CMakeFiles/CMakeOutput.log".
See also "/Users/somebody/Downloads/mathgl-8.0.1/CMakeFiles/CMakeError.log".
I am wondering how can I install hdf4? or is hdf4 already replaced by hdf5?