5
$\begingroup$

In Python, there's something called ctypes. With ctypes, one can call any shared library function and get the results back to your script. It supports all kinds of C-language types, such as int, double, long, struct, etc...

Is this possible with Mathematica too? Is there a full example on how to do this?

$\endgroup$
  • $\begingroup$ Yes, at least on Windows you can do this with .NET/Link. I don't know if it also works on other platforms. .NET/Link does, but it might be more trouble to set up and I do not know if this specific functionality is supported. $\endgroup$ – Szabolcs Jul 15 '16 at 10:48
  • $\begingroup$ Related, perhaps even duplicate?: (22679) $\endgroup$ – Mr.Wizard Jul 15 '16 at 10:48
  • $\begingroup$ Here's how to do it: reference.wolfram.com/language/NETLink/tutorial/… $\endgroup$ – Szabolcs Jul 15 '16 at 10:50
  • 1
    $\begingroup$ @Szabolcs Would be disappointing if it's only for windows... because I do all my tough calculations on Linux. $\endgroup$ – The Quantum Physicist Jul 15 '16 at 10:50
  • 1
    $\begingroup$ @Mr.Wizard I would compare this with Python's C API, not ctypes. Because with C API you need to import some python headers, which is similar to what's given in the question there. The nice thing about ctypes is that you can write a native interface without requiring to import any non-native header from Python. This would be great if available for Mathematica! $\endgroup$ – The Quantum Physicist Jul 15 '16 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.