如何在Mac上完全编译并安装MathGl?
请让我知道,如果有的话,我是否可以在计算机上使用MathGl。如果以下测试有任何错误,请让我知道。
谢谢。
好的,我已经挣扎了很长时间了。这是我尝试从C/Fortran代码可视化结果时发生的情况 基本信息是:
OS: Mac OSX 12.3.1
GCC/GFortran version: 11.3.0
clang version: 13.1.6
案例I:默认情况下,
cmake .
cmake .
make install
这看起来像是最小的安装。标题文件已安装到/usr/local/include,libs已安装到/usr/local/lib。 默认构建能够编译以下代码,如果我运行,
**[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");
}
我相信默认构建足以生成图。但是,该图是生成并自动保存在磁盘上的。如果我要调试我的代码(可能会生成很多地块,而我不需要)就不方便了。可能是,我需要调整一些参数才能获得有前途且物理上可实现的设置。因此,我希望每次运行后直接生成并直接打开图。
案例II:
,我正在尝试运行以下代码,
**[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();
}
在这种情况下,如果我尝试使用默认命令编译代码
**[compile default]**
g++ src/testMathGL.cpp -o testMathGL -lmgl (-lmgl-fltk)
当然,错误是直接的
'mgl2/fltk.h' file not found
,默认构建不包含任何图形库。为了包括这些库,我尝试了MathGl的预制库。我的编译是,
**[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)
但是G ++一直给我带来错误,
unknown type name 'dllimport'
因为预先构建的下载始终具有win64为后缀,我认为对于Unix型系统,我需要自己编译。 从MathGl的安装说明中,我被告知必须在配置制造过程时启用一些键。另请参见 http://mathgl.sourceforge.net/doc_en en/doc_en en/installation.installation.htallation.html
cmake -D enable-all=on -D enable-all-widgets=on -D enable-all-swig=on .
ant它给出了很多错误,说明缺失的依赖性。我发现其中大多数,例如QT5,HDF5,Glut,fltk,Wxwidgets,swig,octave。 现在仍然有一些我不知道如何解决的依赖。正如我所表明的那样,
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".
我想知道如何安装HDF4?还是HDF4已被HDF5取代?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
emmmmm,我现在有一个棘手的解决方案。这是用于显示当前图的呼叫系统应用程序。
仍在寻找编译Mathgl的解决方案...
Emmmmm, I have a tricky solution for my requirement above now. Which is call system applications to display the current plots.
Still looking for solutions to compile MathGL...