Multiple definition error linking



I am a new user of MMG3D and I would like to ask for your help solving a linking error.
I downloaded and compile the latest version from I have no problems running the examples provided with the library. Yet, my objective is to interface MMG3D with a c++ finite element code through its API functions.

I encountered the following linking error:
Linux_64 link with g++
apimesh_Linux_64/Adapt.o:(.bss+0x0): multiple definition of `MMG3D_lenedgCoor’
apimesh_Linux_64/MMG3D_mesher.o:(.bss+0x0): first defined here

Here is an example on how I make use of the library in the previous files :
MMG3D_mesher.h :
#ifndef MMG3D_MESHER_H
#define MMG3D_MESHER_H
#include <mmg/mmg3d/libmmg3d.h>
MMG5_pMesh mmgMesh;
MMG5_pSol mmgSol;

Adapt.h :
#ifndef ADAPT_H
#define ADAPT_H
#include <MMG3D_mesher.h>

Do you have any idea on how to solve this problem?
Thank you,


Hi, I implemented myself the interface between our c++ code and MMG. You can check it here, may be useful as practical case:


Thank you for your help Loumalouomega.

Hello and welcome to this forum Oana. Soory to come back a little late but I am on maternity leave.

Does the Loumalouomega answer solve your problem?




Thank you for the example Loumalouomega, it is of course very useful to have an example and Algiane for your welcoming. Congratulations on your new family member, Algiane!

In my case I chose to define a void pointer in the header file which I cast further in .cpp file. Thus, I only include the mmg library once (as Kratos does) in the .cpp file. This solved my problem.

Best regards,