Personal tools
You are here: Home Forum How to use Salome? Compilation options to use medcoupling in c++

Compilation options to use medcoupling in c++

Up to How to use Salome?

Compilation options to use medcoupling in c++

Posted by Seb P. at January 02. 2018

Hello,

I just discovered medcoupling library and I want to use it in a c++ code but I can't correctly compile the c++ code.

Here is my problem. I wrote an extremely simple code :

- test.cpp :

#include "test.hpp"
#include <MEDCouplingUMesh.hxx>

using namespace ParaMEDMEM;

int main()
{

MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("My2DMesh",2);

return 0;

}

- test.hpp :

namespace ParaMEDMEM
{
  class MEDCouplingUMesh;
}

So I tried to compile it (in salome shell for now but later I'd like to use medcoupling outside salome environment). Here is the command I use for the compilation :

$ salome shell

$ g++ -o toto -g test.cpp -I $MEDCOUPLING_ROOT_DIR/include/ -L $MEDCOUPLING_ROOT_DIR/lib/

In this way, I get the following error :

undefined reference to « ParaMEDMEM::MEDCouplingUMesh::New(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) »
collect2: error: ld returned 1 exit status

I tried to add some includes or libraries but I always get this same error.

 

In case it's useful, here is some additional informations :

- I use salome 7.8

- the command "g++ -v" returns this version : gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5)


Can you explain me how to compile a c++ code using medcoupling ? What compilation options do I have to use ? I didn't find any informations about the compilation in the documentation or the examples given in it.

Thank you for your help.

S.P.

Re: Compilation options to use medcoupling in c++

Posted by Saint Michael at January 03. 2018

Hi S.P.

It seems that the name of MEDCoupling shared library (something like -lMEDCoupling) is missing from the compilation command,

St.Michael

Re: Compilation options to use medcoupling in c++

Posted by Seb P. at January 05. 2018

Hi,

Indeed, it works if I use the option -lmedcoupling.

Thank you.

S.P.

Powered by Ploneboard
Document Actions