2
$\begingroup$

If/when I produce a DLL using, say,

Compile[{{x}}, x^2 + Sin[x^2], CompilationTarget -> "C"]

I know where the DLL is. What I'm wondering is whether I can then call that function from, say, a compiled C or C++ executable. I know how to do this with other DLLs; will the same techniques work for interfacing with the Wolframe DLL? And if they will, is the MMA kernel loaded when the DLL entry point is invoked? Or is the code in the Wolfram DLL independent of the kernel. I realize that this is unlikely, but it seems it might be possible for non-UI mathematica code.

$\endgroup$
2
$\begingroup$

Yes, this is possible for functions that can be compiled to a DLL.

If CompilationTarget -> "C" can be used successfully, that means the compiled function does not make any calls to the main evaluator.

In other words, the compiled function is in fact independent of the kernel, however its DLL still must link to the Wolfram Runtime Library (RTL).

This is discussed in the documentation, particularly in the Code Generation tutorial. See also this example of making a standalone executable.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.