Here are some notes:
- For Arch user, install
mathematicaormathematica-light. - Check if your shell is
zshell. - Change the
WOLFRAMandWSTP_PATHvariable inrun.sh.
Build it with command:
# build
./run.sh wstp_repl.c
# after building, simply run
./wstp_replCommands list as follows, take wstp_type=NET as example:
# launch server(wolfram kernel)
wolfram -script wstp_server.wls
# build & run client
./run.sh wstp_client.c
# after building, simply run
./wstp_client "2^64"
./wstp_client 'num1=2^64; Print["Hello From wstp client"]; num1'
./wstp_client '<< "example.wls"'
./wstp_client 'Integrate[Sin[x]/x^3, x]'
./wstp_client "Integrate[Sin[x], {x, 0, 2/3*Pi}]//TeXForm//ToString"File example.wls contains just 3 lines:
(* This is file 'example.wls' *)
TeXResult=ToString[TeXForm[LaplaceTransform[t^4 Sin[3*t], t, s]]];
Export["output.txt",TeXResult]WARN:
wstpwill only print the last experssion that does not followed by a semicolon inwstp '<< "<file>"'syntax.
Currently, wstp_client only has a limited support for image generating(export), check wstp_client_img.c for details.
A simple example:
./wstp_client -i "Plot[Sin[x], {x, 0, 2*Pi}]"
./wstp_client -i "Plot[Sin[x], {x, 0, 2*Pi}]" -o 'test.png'In the first case, you'll see a figure named output.png appears in current directory.
WARN: do NOT support exporting pictures in vector format, such as
SVGetc.
This repo provides some scripts(config) to make wstp_client and wstp_server work with other programs:
Some materials about WSTP:
- WSTP and External Program Communication Overview
- Using WSTP to Communicate between Wolfram System Sessions
- Running the Wolfram System from within an External Program
- WSTP Packets
Deeply appreciate the innovative tools provided by Wolfram Research.