How to use API for libexamples?

I am trying to use the API function to run the examples in libexamples folder, but the Cmakelist is used for generating exe rather than libraries. Did any one has some quick tutorial for using the API? Another question is that can we directly use the API in our own codes as a built-in package likes the gmsh API, only uses the API header file and dynamic library link?
Many thanks.

Hi,

Normally, static Mmg libraries are automatically compiled because the following CMake’s cache variables defaults to ON:

  • LIBMMG3D_STATIC
  • LIBMMG2D_STATIC
  • LIBMMGS_STATIC
  • LIBMMG_STATIC

If they are setted to OFF you can try to enbable them using CMake’s GUI or with the following command line:

cmake -S. -Bbuild -DLIBMMG3D_STATIC=ON -DLIBMMG2D_STATIC=ON -DLIBMMGS_STATIC=ON   -DLIBMMG_STATIC=ON  

You can build the examples stored in the libexamples by enabling explicitely the following CMake’s flags:

  • TEST_LIBMMG
  • TEST_LIBMMGS
  • TEST_LIBMMG2D
  • TEST_LIBMMG3D

Again, you can use the CMake’s GUI or the following command line:

cmake -S. -Bbuild -DLIBMMG3D_STATIC=ON -DTEST_LIBMMG2D=ON  -DTEST_LIBMMGS=ON -DTEST_LIBMMG=ON  

Some documentation on libraries compilation and tests are available on the github repository of the project: Tools for the mmg libraries users · MmgTools/mmg Wiki · GitHub.

You can indeed use the API in your own code, using either a static (as explained here) or shared library link (for which you just have the replace the static keywords of CMake’s variables by th shared ones.

I hope that it will help.
Best

Hi,
Thanks for your reply. This problem is well solved when I use cmake-gui to generate the project.
Regards

Thanks for the feedback!