Interface Freefem++ with C++

Hello users,

I have an object-oriented code written in C++ and I would like to call FreeFem to solve a FE problem. So, how can I interface FreeFem with C++ ? I know it’s possible with Python. Is it also possible with C++ ? If so, can I have an example ?

Thanks !

Lily

Hi @Lily,

Generally speaking, you cannot call FF as an API in your programs, neither in C++ nor Python. But, if you mean you want to call it as an external program, it can be done in C++ with a system call. This sort of offline linking is always possible, in which you call FF executable to solve a problem and write the solution the disk (you wait for it), and then, you collect the answer in your own code.

Another solution, which of course requires more effort and some architectural changes to your code, is the other way around. I mean you can call your C++ codes in FF as external functions (and not an external executable binary). It’s possible to build C++ codes as dynamics libraries and load them inside FF as a sort of plugin. FF comes with a script called ff-c++ that makes this process easier. You can find a couple of examples for various types of functions in FF website and examples.

Hello @mojtaba.barzegari,
Thank you ! It works fine with a system call in C++