I am trying to link a 3rd party library in FreeFem++ called cwipi, the library in coded in C++. I changed the pref file to link the .so and the .h files but it did not work (I can load the library but I can’t use any function). I was wondering if I should transform the c++ functions then compile with ff-c++, but that’s a tedious task… Is there any way to directly link 3rd party libraries?
I was wondering if I should transform the c++ functions then compile with ff-c++
That is exactly what you need to do. FreeFEM can’t guess what functions you need from the library, so you need to interface them yourself. There are many examples in plugin/seq/ and plugin/mpi/.
I see, I tried correcting with the above modifications: linktocwipi.log (815 Bytes)
I’m still getting the following error: invalid conversion from ‘long int ()(std::__cxx11::string, long int)’ {aka ‘long int (*)(std::__cxx11::basic_string*, long int)’} to ‘OneOperator2_<long int, std::__cxx11::basic_string*, long int>::func’ {aka ‘long int ()(std::__cxx11::basic_string const&, const long int&)’} [-fpermissive]
Please look at some more examples and see what your compiler is telling you. You cannot use values, but need to pass const references instead, see, e.g., plugin/seq/BinaryIO.cpp:Global.Add("LoadFlag", "(", new OneOperator2_< double, long int *, string * >(LoadFlag));
In case some of you would like to employ the openmp parallelization from your library, you would need to add the flag -fopenmp in the ff-c++ file, line 8