[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] [TeXmacs] Mathematica plugin on OS X

From: BB
Subject: Re: [Texmacs-dev] [TeXmacs] Mathematica plugin on OS X
Date: Thu, 1 Sep 2016 12:23:08 +0200

Hi everybody,

I try to get the Mathematica plugin to work on OS X 10.9.5 and 10.9.6   with mathematica 10.2.0  and some versions TeXmacs  ( including  Qt-based 1.99.5 and the last Fink distributions )

For doing that, I used an installer ( written in Mathematica, you can find it here )  which gave good results on Mac OS  10.8 with Texmacs 1.0.7 , and I tried  to improve it , taking into account the modifications suggested by Peter and  Tian-Min.
Without surprise I got the a similar result ( fig 1: « En cours »= « in progress »,  in French ).

Using the command ‘top’, I noticed that tm_mathematica and the mathematica kernel are initially launched when we start the session  ( fig 1 )
but both vanishe soon after an attempt to use mathematica ( fig 2 ).

    ( fig 1 )

   ( fig 2 )



Le 28 juin 2016 à 04:14, Peter Rapčan <address@hidden> a écrit :

Hello everybody,

I tried to get the Mathematica plugin to work on OS X 10.11.5, TeXmacs 1.99.4, with Mathematica

First of all, I copied the tm_mathematica.c from Tian-Min Yan to the /Applications/TeXmacs.app/Contents/Resources/share/TeXmacs/plugins/mathematica/src.lazy/ directory.

Then I performed two changes to the file:
- replaced all occurences of MLDisownString by MLReleaseString
- replaced all occurences ofMLDisownSymbol by MLReleaseSymbol
(According to the Wolfram documentation, as of Mathematica 6.0 the former functions have been superseded by the latter functions. I am not sure from which version of Mathematica the old functions cannot be used; in any case I could not compile the tm_mathematica.c with the libMLi3.a choice without these changes in the case of  Mathematica I suppose these changes need to be done also if one wanted to use the stock tm_mathematica.c provided in a TeXmacs installation.

The adapted tm_mathematica.c  is file is in the attached.

Next, I used the script provided by Singh Madhusudan and made some changes to make it work. The changes I had to make are the following:
- change the Mathlink_Path variable (Mathematica version 9 or greater contains the architecture specification [in my case MacOSX-x86-64] in the path to the directory where Mathlink resides).
- change the /usr/lib/ to /usr/local/lib/ since from OS X 10.11 the System Integrity Protection is enabled, forbidding to write to the /usr/lib/ directory irrespective of administrator rights.
- change the compiler commant to use g++ instead of gcc and use the oprion -l$lib_option -stdlib=libstdc++ instead of the -l$lib_option -lstdc++

With these changes, running the script compiled the tm_mathematica.c just fine, with a single warning “tm_mathematica.c:544:46: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long')
   printf("\2prompt#\\red In[%1d]:= {}\5\5",InNum++);”

I attach the working script as “tmMMAscript".

Next, as TeXmacs did not recognize Mathematica as available in the list of supported sessions, I created a wrapper “math” command that runs the MathKernel  and placed in into /usr/local/bin/. The wrapper is attached. (note that creating a symlink to MathKernel does not work). After doing this, TeXmacs offers the Mathematica session in its list of supported sessions.

Upon including a Mathematica session, I was prompted whether I allow tm_mathematica.bin to accept incoming connections, from which I deduce the MathLink is working… well… almost. Unfortunatelly, the session does not return results of computations; instead it shows a “busy…” message (see the attached screenshot).

<Screen Shot 2016-06-28 at 03.43.48.png>

I looked at the tm_mathematica file provided by TeXmacs, and tried to tweak it (I think the paths are based on some old mathematica version, so I changed the relevant command to

export MATHLINK_PATH="$MATH3/CompilerAdditions"


export MATHLINK_PATH="$MATH3/CompilerAdditions/AlternativeLibraries"
(According to the readme file provided in the AlternativeLibraries directory: “This AlternativeLibraries directory contains a versions of the MathLink
libraries compiled with -stdlib=libc++ compiler flags.  These libraries exist to link programs that need compatibility with Apple's newer libc++ C++ library.”
Since I compiled with the -stdlib=libstdc++ option the second choice should be the correct one).

In any case, none of the changes I tried to make to the tm_mathematica file helped to make the plugin work, hence I am stuck with the busy message. Any help to resolve the issue would be greatly appreciated.



On 31 Oct 2012, at 11:35, Tian-Min Yan <address@hidden> wrote:

Hi all,

Now I know how to output PS/EPS graphics. According to the manual
section "Interfering TeXmacs with other programs", I simply put

  fputs("\2ps:", stdout);
  system("cat ~/tmp.eps");
  fputs("\5{}{}\n\n", stdout);

into the code (see the attachment), now the EPS figure shows up. Can we
adjust the size and the position of the figure within TeXmacs?

Besides, I am wondering if we can display a PNG file, since those
rasterized formats have significantly smaller size and the program runs
faster. We should be able to choose between different formats to meet
different purposes.

One more question, can anybody who is familiar with Mathematica figure
out why "Export["./tmp.eps", expr]" sometimes outputs figures in the
wrong position, as is shown in the attachment where the main part is not
at the center? In contrast, PNG file does not have this problem.


On Tue, 2012-10-30 at 19:01 +0100, address@hidden
Hi Tian-Min,

The plugin worked perfectly for graphics in old times when Mathematica
produced pure postscript graphics (this was in versions <=5).
If you are happy with the old-style Mathematica graphics, in your
mathematica session simply evaluate : Get["Version5`Graphics`"]
and then the plugin will recognize the ps graphics and show them in
TeXmacs (but only for old -or unchanged- graphics functions, old options

It would be nice to benefit from the new mathematica graphics, but that
would require someone to volunteer for improving the plugin in that area.


Tian-Min Yan - address@hidden wrote:
Hi all,

I am using Mathematica 8. The Mathematica plugin in TeXmacs works
perfectly with a single _expression_ if it does not contain graphical
elements. But if we use functions involving plots, the output is
problematic. Has anybody figured out the implementation of embedded
figures with the Mathematica plugin?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]