mutationpp / Mutationpp

The MUlticomponent Thermodynamic And Transport library for IONized gases in C++
GNU Lesser General Public License v3.0
101 stars 58 forks source link

calling Mutation++ from C program? #253

Closed jaredmagnusson closed 4 months ago

jaredmagnusson commented 6 months ago

Hello, I'm looking to couple Mutation++ to an existing C-program. I see that you've already implemented a cwrapper.h/cpp for your Fortran interface. would I be able to simply link to the resulting shared library directly for coupling?

rdbisme commented 6 months ago

Ehi @jaredmagnusson. Had you the chance to look at this: https://github.com/mutationpp/Mutationpp/blob/master/docs/coupling.md?

jaredmagnusson commented 5 months ago

Yes, so I was able to compile the cwrapper.cpp as a separate library (libmutation++_c.so), and add cwrapper.h to the include dir. but linking to that is the issue, I get undefined symbol errors for mpp_initialize, not sure if the name mangling is happening in the same way as it would with Fortran

jaredmagnusson commented 5 months ago

Nevermind I figured it out. There is a trailing underscore on the mppinitialize(), to account for the Fortran naming. Adding that I got it to work

jaredmagnusson commented 5 months ago

I think cwrapper.h may be missing an #include <stdbool.h> for the has_electrons function

mgoodson-cvd commented 4 months ago

@jaredmagnusson you are correct on the missing #include <stdbool.h>. I'll make a PR to fix that, which will close this issue.

raj-brown commented 1 month ago

Yes, so I was able to compile the cwrapper.cpp as a separate library (libmutation++_c.so), and add cwrapper.h to the include dir. but linking to that is the issue, I get undefined symbol errors for mpp_initialize, not sure if the name mangling is happening in the same way as it would with Fortran

How did you compile it to c library. Could you please share the CMake file for that.. Thanks!