There is a filename.c library of custom functions at my work that I would like to
access using Mathematica. What is your method for calling c functions using J/Link? I have
J/Link and I can get 50% of the examples to run on my PC. Is there any hope for me
of this being easy?
Chris French
Murphy wrote:
> At 00:02 25.08.00 -0400, you wrote:
> >Hi all,
> > I am trying to let the mathematica kernel evaluates for me something from
> >a c program. I am using the "simple example " from Todd Gayley MathLink
> >tutorial page 24 .After calling the excutabe file(call it add) through:
> >add -linkname'math-mathlink'-linkmode launch ;
>
> did you type it like that? the problem might be in some missing blanks:
> try: -linkname "math -mathlink" -linkmode launch
>
> I am using J/Link, so I'm not an expert on pure mathlink;
>
> >it seems to me that the progrm is compiled
>
> what do you think is being compiled ?
>
> >and it instructs me to
> >enter two numbers.After I entered them it instructs me as:
> >Create Link :Connect to link.
>
> what do you mean by "instructs me"?
> does it tell you that it is creating the link or are you supposed to enter
> something here?
>
> >What I should do now.Whatever I type in the computer goes in a very long
> >sleep!!!!
>
> is this one of the prebuilt samples from the developer kit or your own program;
> do the other samples from the developer kit work?
> what Operating system are you working with?
>
> murphee
>Murphy,
>
>There is a filename.c library of custom functions at my work that I would like to
>access using Mathematica. What is your method for calling c functions using J/Link? I have
>J/Link and I can get 50% of the examples to run on my PC. Is there any hope for me
>of this being easy?
>
>Chris French
Chris,
The reason some of the J/Link examples are not working for you is that
they use the Swing GUI library. You are using the Microsoft Java
runtime, which does not include Swing. I think you'll find that if you
install Sun's Java runtime
(http://www.javasoft.com/j2se/1.3/download-windows.html), all the
examples will work fine.
I would not recommend using J/Link to call C functions. J/Link makes
it trivial to call Java functions from Mathematica, but to call C
functions you'd have to write stub C code that wrestles with the Java
Native Interface (JNI), which is at least as complex as dealing with
raw MathLink from C. You are probably better off just using the
standard "template" mechanism for accessing C functions from
Mathematica via MathLink.
--Todd
Todd Gayley
Wolfram Research