Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Setting up external functions to be called from Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82361] Setting up external functions to be called from Mathematica
  • From: pinksheep415 <selim50 at gmail.com>
  • Date: Thu, 18 Oct 2007 04:58:13 -0400 (EDT)

Hi,

I'm trying to figure out how to call an external function from
Mathematica.  Examples I've found so far doesn't give enough
informations for a newbie like myself.

The following is content of an example MathLink template file, f.tm:

:Begin:
:Function:      f
:Pattern:       f[x_Integer, y_Integer]
:Arguments:     {x, y}
:ArgumentTypes: {Integer, Integer}
:ReturnType:    Integer
:End:

1.  How do I create a MathLink template?  Can I just use text editor
and save it with .tm extension?  Where should the file be saved?

Following is the content of an example c code, I named it f.c:
#include "mathlink.h"

int main(int argc, char *argv[]) {
return MLMain(argc, argv);
}

int f(int x, int y) {
return x+y;
}

2.  Although I copied "mathlink.h" file into INCLUDE folder for C
compiler (I'm temporarily using Dev-C++), the compiler doesn't
recognize MLMain(argc, argv);  Can anyone tell why?  Does this have to
do w/ the kind of compiler I'm using?  Does this c file need to be in
the same folder as the above .tm file?

3.  After I get these files saved in the right folders, how do I use
them?
Any help would be greatly appreciated!!!

-selim50 at gmail.com



  • Prev by Date: Re: Palette for Units Conversion
  • Next by Date: Debugging with v6
  • Previous by thread: Transparency & EPS
  • Next by thread: Re: Setting up external functions to be called from Mathematica