Message Boards Message Boards

How to call C functions from Mathematica compiled C functions?

Posted 8 years ago

I've been mucking about with CCompilerDriver, trying to ship Mathematica born logic into little test programs.

The established procedure seems to be:

  • Compile and export a function to C code
  • Write a C program to call that C code

Complications arise when wanting to call other C functions from the compiled Mathematica code. One could manually inject appropriate includes and calls into the generated .c files, but this undermines the automation I'm interested in.

Long story short I don't know if this is possible, or where to start my investigation. All suggestions welcome!

Optimistic first attempt in the attached notebook.

Attachments:
POSTED BY: David Gathercole

I've deduced that if a C compiled function references another C compiled function at export, the sub function is exported to .c with it. This represents a large part of the functionality I was inquiring after, but it does raise further questions.

For example, if I compile functions A, B, and C, C and B both using A; and export C and B to .c separately, is A duplicated?

This could yield an angle of attack for the broader question of 'how to link in C from compiled C', but I don't yet see it.

POSTED BY: David Gathercole
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