[comp.sys.next] mathlink

dorner@pequod.cso.uiuc.edu (Steve Dorner) (11/22/89)

I'm posting this for a friend. Please reply to him, not me.

-----------------------------------------------------------------------
I would like to extend Mathematica by installing some C procedures.
According to the on-line documentation, this should be easy to do
using the interface procedures defined in the file mathlink.c  Unfortunately,
mathlink.h is empty and I have apparently not added the correct function
prototypes to make mathlink.c work.  Would anyone who has been successful
with mathlink please pass along some pointers (sorry the pun was intended).

I have also tried to communicate with Mathematica using pipes.  I've had
some success; however, when I send the string
  "ResetMedium[\"stdout\",PageWidth->Infinity]; $PrePrint=FullForm"
I get a message saying the Mathematica cannot parse the expression.
Any suggestions?


chuck fleming
cfcgf@ecncdc.bitnet
-----------------------------------------------------------------------

-- 
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: {convex,uunet}!uiucuxc!dorner
IfUMust:  (217) 244-1765

dorner@pequod.cso.uiuc.edu (Steve Dorner) (11/23/89)

I'm posting this for a friend. Please reply to him, not me.

-----------------------------------------------------------------------
To anyone interested in communicating with Mathematica using pipes.
It's pretty easy to do. To set up communication I used the source code in

/NextLibrary/Documentation/Mathematica/UnixSummary.wn

However, I could only get this code to run on my NeXT  after the following
changes in the code were made.

1)  mmapath = usr/local/bin/math    should be  mmapath = usr/bin/math

2)  every occurrence (including those occurring in strings sent to
    Mathematica)   of   //    should be replaced by   /

3)  there should be only one call to   fetchresult()  to absorb
    initialization messages harmessly (not two)

chuck fleming
cfcgf@ecncdc.bitnet
-----------------------------------------------------------------------

-- 
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: {convex,uunet}!uiucuxc!dorner
IfUMust:  (217) 244-1765

dorner@pequod.cso.uiuc.edu (Steve Dorner) (12/04/89)

I'm posting this for a friend.  Please reply to him, not me.

--------------------------------------------------------------------------
To anyone interested in using mathlink,

If you compile mathlink.c (in NextApps/Mathematica.app/Kernel/Utilities)
you get a list of warning messages basically of the form  "function
implicitely declared and later declared static". To get rid of these, for each
function that was being declared implicitely, put its prototype in the
external functions where it was being called. This gets rid of all warning
messages except for "missing _main" which you should still be getting.
Incidently, mathlink.h is empty and can stay empty.

To test mathlink you can use the sample program given in
NextLibrary/Documentation/Mathematica/UnixSummary.wn (on page 28).
I copied the code and called it "sample.c".  Be sure to replace all
occurrences of "\\" by  "\".  (Check for "\\"'s in mathlink.c. If you find
any, replace them by "\"'s.)

Then from a shell do:   cc -fwritable-strings mathlink.c sample.c
to complike and link the programs (the executable will end up in
a.out).  Thank Bruce Bruce Blumberg for the correct compiler option.

Start Mathematica and type:      StartProcess["path"]
where path is the full pathname of the executable file generated by
the cc above.   Path will be something like   /me/programs/a.out .
Mathematica should return a list  {BitAnd, CheckSum}, which contains
the C functions that were installed and can now be used like any other built-
in Mathematica functions.

chuck fleming
cfcgf@ecncdc.bitnet

--------------------------------------------------------------------------




-- 
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: {convex,uunet}!uiucuxc!dorner
IfUMust:  (217) 244-1765