0

I have followed this tutorial to create an FFI interface to some C code to torch

However, it doesn't work for C++ functions. Is it even possible, if so how?

I created a shared library from the C++ file (simple.cpp) like so:

g++ -Wall -shared -fPIC -o libsimple.so simple.cpp
StarLord
  • 1,012
  • 1
  • 11
  • 22

1 Answers1

1

The C++ functions need to have C linkage to be used via FFI. Wrap the function signatures with extern "C" calls. More details here: In C++ source, what is the effect of extern "C"?

Community
  • 1
  • 1
smhx
  • 2,246
  • 18
  • 22