How to compile into a dynamic link library?

I tried to compile the static library and successed. But failed when I try to compile the dynamic link library(change the value BUILD_SHARED_LIBS in CMakeLists.txt to ON).I know that mmg is LGPL license.Does it means that I can only use the dynamic link library?But how can I compile it successfully?

Hi,

Yes, Mmg is LGPL. Normally it should be possible to build it in shared library mode but we may have a CMake issue. Maybe you can try to set explicitely the LIBMMG<X>_SHARED flags to ON?

Do not hesitate to attach the CMake log here so I can try to help you.

Best Regards,
Algiane

I git clone the code,and set BUILD_SHARED_LIBS in CMakeLists.txt to ON。

,configue and generate successfully. I use visual studio 2019,and then I compile. but It has link error .It means could not find .lib, and I checked all the folders,there is no .lib generated. I use Windows 11 platform.

I’ll elaborate on my compilation process.
1 First, git clone the code, succeed.
2 Then set BUILD_SHARED_LIBS in CMakeLists.txt to ON。
image

3 set cmake
image

4 configure and generate succeed.
image

5 compile by visual studio 2019
image

There is link error means that can not find .lib file,. and I checked all the folders,there is no .lib generated. Why?

Hi,

Thank you for the feedback. I can reproduce the issue (it is due to the fact that we don’t export symbols needed with shared library in a clean way and it creates errors under Visual Studio).

I will try to find time on monday to fix this!

Regards,
Algiane

Another question,LGPL allow commecial software to use dll library,right? And will you add a parameter to track the progress of your functions, because If I want to build a software,I need to add a progressBar.
It is not good to let software users to wait without knowing when will this algorithm finish.

Hi,

As I don’t know much about compiling under windows (and I don’t have a graphical windows at hand), a colleague offered me help to fix the shared libraries error: I think he will have a fix for the end of the week at the latest.

Regarding the addition of a progress bar:
It is difficult to have a guess of the total time the remeshing process will take (because it is an iterative process that has to converge, because our operators are subject to cache misses that are hard to predict, to array reallocations for large meshes, etc…). But increasing the Mmg verbosity adds information (in the terminal) about the refinement waves that are taking place, which can correspond in a certain sense to a progress status, or at least which let the users know that the process make progress.
Would this work for you?

Best,

[quote=“Algiane, post:7, topic:625”]
But increasing the Mmg verbosity adds information (in the terminal) about the refinement waves that are taking place, which can correspond in a certain sense to a progress status
[/quote] I do not know what is this sentence mean?can you show me the screenshot of the related codes?

Hi,

When calling Mmg in library mode, you can ask for a higher verbosity than the default one using the following API function:

  /* Set verbosity to 5 (default value = 1) */
  if ( MMG3D_Set_iparameter(mmgMesh,mmgSol,MMG3D_IPARAM_verbose, 5) != 1 )
    exit(EXIT_FAILURE);

With Mmg3d I have the attached terminal output.

  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   MODULE MMG3D: 5.6.0 (Nov. 05, 2021)
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
     git branch: master
     git commit: 565d684981442a421307726f1dc2c76ba7728099
     git date:   2022-04-13 10:58:36 +0200


  -- MMG3DLIB: INPUT DATA
  --  INPUT DATA COMPLETED.     0.000s

  -- PHASE 1 : ANALYSIS

  -- MESH QUALITY  13901
     BEST   0.996633  AVRG.   0.806049  WRST.   0.244425 (11976)
     HISTOGRAMM:  100.00 % > 0.12
                   99.47 % >  0.5
       0.8 < Q <   1.0      7986    57.45 %
       0.6 < Q <   0.8      5237    37.67 %
       0.4 < Q <   0.6       673     4.84 %
       0.2 < Q <   0.4         5     0.04 %

  ** SURFACE ANALYSIS
     Connected component: 1,  genus: 0,   reoriented: 0
     Edges: 4035,  tagged: 306,  ridges: 153, required: 0, refs: 153
     153 ridges, 0 edges updated
     8 corners, 8 singular points detected
  ** DEFINING GEOMETRY
     1198 normals,  141 tangents updated  (0 failed)
     0 required edges added
     0 corner and 0 required vertices added
  -- PHASE 1 COMPLETED.     0.076s

  -- PHASE 2 : ISOTROPIC MESHING
  ** MESH ANALYSIS
  ** GEOMETRIC MESH
                               0 splitted,        0 collapsed,      152 swapped
  ** COMPUTATIONAL MESH

  -- GRADATION : 1.300000 (2.300000)
     gradation:       0 updated, 1 iter.
                               0 splitted,     2898 collapsed,      274 swapped
                               0 splitted,      152 collapsed,       21 swapped
                               0 splitted,       17 collapsed,        1 swapped
                               0 splitted,        2 collapsed,        0 swapped
                              15 splitted,        0 collapsed,       17 swapped
            0 filtered,        0 splitted,        9 collapsed,        6 swapped,        9 moved
            0 filtered,        0 splitted,        4 collapsed,        1 swapped,        3 moved
                                                   0 improved,        1 swapped,        1 moved
            0 filtered,        0 splitted,        2 collapsed,        0 swapped,        1 moved
            0 filtered,        0 splitted,        1 collapsed,        0 swapped,        0 moved
  -- PHASE 2 COMPLETED.     0.956s

  -- MESH QUALITY  14
     BEST   0.719588  AVRG.   0.679508  WRST.   0.665108 (2)
     HISTOGRAMM:  100.00 % > 0.12
                  100.00 % >  0.5
       0.6 < Q <   0.8        14   100.00 %

  -- RESULTING EDGE LENGTHS  30
     AVERAGE LENGTH               0.4888
     SMALLEST EDGE LENGTH         0.2500       40    948
     LARGEST  EDGE LENGTH         0.7071       39     12
     0.71 < L < 1.41         5   16.67 %

     HISTOGRAMM:
     0.00 < L < 0.30         1    3.33 %
     0.30 < L < 0.60        24   80.00 %
     0.71 < L < 0.90         5   16.67 %

  -- MESH PACKED UP
     NUMBER OF VERTICES         10   CORNERS        8
     NUMBER OF TETRAHEDRA       14
     NUMBER OF EDGES            12   RIDGES        12
     NUMBER OF TRIANGLES        14

   MMG3DLIB: ELAPSED TIME  1.074s

  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   END OF MODULE MMG3D
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

output.txt (4.2 KB)

I hope that it helps,
Best Regards

1 Like

Hi @song_wang ,

The compilation of the Mmg shared libraries is now fixed inside the develop branch of Mmg (thanks to an external contribution).

Do not hesitate if you still have troubles.

Best Regards,
Algiane

thanks I will try soon