Multiple definition error linking


#1

Hello,

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 https://github.com/MmgTools/mmg.git. 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>
class MMG3D_MESHER
{
protected:
MMG5_pMesh mmgMesh;
MMG5_pSol mmgSol;
….
#endif

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

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


#2

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


#3

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?

Regards,

Algiane


#4

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,
Oana