Message Boards Message Boards

GROUPS:

Use the C Compiler with Mathematica online?

Posted 3 years ago
5709 Views
|
4 Replies
|
4 Total Likes
|

I have a student online Mathematica account (without a desktop version). I was trying to use the Compile function and compile something to C:

cf = Compile[{{j, _Integer}},(2-If[j==0,1,0])*Integrate[ChebyshevT[j,x]*(2*x+3)*Log[2*x+3]/Sqrt[1-x^2] ,{x,-1,1}]/Pi,CompilationTarget->"C"]

but got the following error:

CCompilerDriver`CreateLibrary::nocomp : A C compiler cannot be found on your system

Does the Wolfram Cloud not support the Compile functio

4 Replies
Posted 3 years ago

The Wolfram Public Cloud does not allow you to compile to C with CompilationTarget -> "C". The default "WVM" compilation seems to work, however.

Posted 3 years ago

The desktop version does allow it? Do you know what can I do if I want to use that piece of code outside of Mathematica? (I understand that if I compile it and export to file I can use it outside, am I wrong?).

I understand that if I compile it and export to file I can use it outside, am I wrong?

It's not as simple as that. It is possible to convert a Compiled function into C code, which can then be used as a component in your C project. You would need to link against the WolframRTL shared library, which comes with desktop Mathematica (I have no idea about the license terms of distributing WolframRTL).

The set of functions that can be used in such a compiled function is limited, and making everything work would take some effort.

Anything symbolic, such as Integrate, will absolutely not work. Many otherwise numerical functions, such as ChebyshevT, also won't work. Check here for a method to rule out most such functions: https://mathematica.stackexchange.com/a/1105/12

Here's the relevant documentation for generating stand-alone code:

Posted 3 years ago

Thank you very much both of you.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract