Getting the Maple plugin working – succeeding to compile tm_maple_9

I wonder if anyone has got a recent version of Maple running in a TeXmacs session?

I’m running Maple 2024 on an iMac-M3 under macOS 14.5 having the latest MacPorts libraries and compilers installed. This is what I’ve done and figured out sofar:

  • I’ve created the soft link

sudo ln -sf /Library/Frameworks/Maple.framework/Versions/Current/bin/maple /usr/local/bin/maple

so that maple is in the path. Note that maple is a shell script that reads in $MAPLE/bin/maple.system.type, and on my system, sets $SYS_TYPE to bin.APPLE_ARM64_MACOS. This implies that the maple cli is the ARM binary.

  • Next, I copied Joris’ maple plugin that ships with latest TeXmacs-2.1.4.m1.signed.dgm as of 2024/05/03 to $HOME/.TeXmacs/plugins/maple.

  • Then I edited the make-file Makefile.9:
    a) uncommenting the PATH settings in lines 13-15, and
    b) adjusting MAPLE_LDFLAGS to fit my system type, bin.APPLE_ARM64_MACOS

  • Running

make -f Makefile all

ended with

make: Nothing to be done for ‘all’,

as there is already a (pre)compiled binary tm_maple_5 in $HOME/.TeXmacs/plugins/maple/bin/. Note, I later on compiled tm_maple_5 for my computer. Yet this did non have a positive impact on the steps carried out below.

  • Finally I ran

make -f Makefile.9 all

receiving 6 error messages (see file below). As a result of this run

  1. a shell script tm_maple_9.sh is created in $HOME/.TeXmacs/bin, which is basically identical to the maple shellscript in /Library/Frameworks/Maple.framework/Versions/Current/bin/maple except for the end where it wants to read in the binary tm_maple_9,

  2. however that binary is not created during the compile run.

  3. Subsequently, trying to launch a maple session results in a freeze.

As I’m not a C programmer, the error messages below are all Greek to me. Does anyone know
→ what they exactly mean?
→ how they can be fixed?
→ have an idea how to get the plugin going, i.e., get tm_maple_9 compiled?

Any help and suggestions appreciated.

Cheers, Tilda

Error messages produced by running make:

make -f Makefile.9 all
cat /Library/Frameworks/Maple.framework/Versions/2024/bin/maple | sed 's%${MAPLE}/$MAPLE_SYS_BIN/cmaple%${HOME}/.TeXmacs/bin/tm_maple_9%' | sed 's%${MAPLE}/$MAPLE_SYS_BIN/maplew%${HOME}/.TeXmacs/bin/tm_maple_9%' > /Users/tilda/.TeXmacs/bin/tm_maple_9.sh
chmod a+x /Users/tilda/.TeXmacs/bin/tm_maple_9.sh
gcc -L/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -Wl,-rpath,/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -lmaplec -I/Library/Frameworks/Maple.framework/Versions/2024/extern/include src.9/tm_maple_9.c -o /Users/tilda/.TeXmacs/bin/tm_maple_9

src.9/tm_maple_9.c:115:31: error: incompatible function pointer types initializing ‘void ()(void *, int, const char *)’ with an expression of type ‘void (void *, int, char *)’ [-Wincompatible-function-pointer-types]
MCallBackVectorDesc cb = { textCallBack,
^~~~~~~~~~~~
src.9/tm_maple_9.c:116:10: error: incompatible function pointer types initializing 'void (
)(void *, intptr_t, const char )’ (aka 'void ()(void *, long, const char *)’) with an expression of type ‘void (void *, intptr_t, char *)’ (aka ‘void (void *, long, char *)’) [-Wincompatible-function-pointer-types]
errorCallBack,
^~~~~~~~~~~~~
src.9/tm_maple_9.c:144:3: error: call to undeclared library function ‘strcpy’ with type ‘char *(char *, const char *)’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
strcpy (init, “read (‘”);
^
src.9/tm_maple_9.c:144:3: note: include the header <string.h> or explicitly provide a declaration for ‘strcpy’
src.9/tm_maple_9.c:145:3: error: call to undeclared library function ‘strcat’ with type ‘char *(char *, const char *)’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
strcat (init, tm_path);
^
src.9/tm_maple_9.c:145:3: note: include the header <string.h> or explicitly provide a declaration for ‘strcat’
src.9/tm_maple_9.c:160:15: error: call to undeclared library function ‘strlen’ with type ‘unsigned long (const char *)’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
while (in[strlen(in)-1] == ‘;’) in[strlen(in)-1]= ‘\0’;
^
src.9/tm_maple_9.c:160:15: note: include the header <string.h> or explicitly provide a declaration for ‘strlen’
src.9/tm_maple_9.c:161:9: error: call to undeclared library function ‘strncmp’ with type ‘int (const char *, const char *, unsigned long)’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (strncmp (in, “quit”, 4) == 0) break;
^
src.9/tm_maple_9.c:161:9: note: include the header <string.h> or explicitly provide a declaration for ‘strncmp’
6 errors generated.
make: *** [/Users/tilda/.TeXmacs/bin/tm_maple_9] Error 1

I have no idea of how things work. This said I would first do what the compiler suggests: add

#include <string.h>

at the beginning of tm_maple_9.c together with the other #include instructions.
Then we might be able to see what else is necessary.

1 Like

Dear Giovanni, as you suggested I added

#include <string.h>

at the beginning of tm_maple_9.c right before the other #include instructions.

It sill doesn’t compile. Yet the the number of errors is reduced to 2. That is, the last four error messages have disappeared. (See below).

Cheers, Tilda

make -f Makefile.9 all
gcc -L/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -Wl,-rpath,/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -lmaplec -I/Library/Frameworks/Maple.framework/Versions/2024/extern/include src.9/tm_maple_9.c -o /Users/tilda/.TeXmacs/bin/tm_maple_9

src.9/tm_maple_9.c:116:31: error: incompatible function pointer types initializing ‘void ()(void *, int, const char *)’ with an expression of type ‘void (void *, int, char *)’ [-Wincompatible-function-pointer-types]
MCallBackVectorDesc cb = { textCallBack,
^~~~~~~~~~~~
src.9/tm_maple_9.c:117:10: error: incompatible function pointer types initializing 'void (
)(void *, intptr_t, const char )’ (aka 'void ()(void *, long, const char *)’) with an expression of type ‘void (void *, intptr_t, char *)’ (aka ‘void (void *, long, char *)’) [-Wincompatible-function-pointer-types]
errorCallBack,
^~~~~~~~~~~~~
2 errors generated.
make: *** [/Users/tilda/.TeXmacs/bin/tm_maple_9] Error 1

It may be that the expressions defining textCallBack and errorCallBack in lines 84 and 90 need to be changed (it is a guess).
I need more time to figure it out (and I might not be able), but let me propose this quick test (which may be nonsensical, because my guess on the meaning of the error may be wrong and I am not able to figure it out in a principles way).

Substitute line 84, which now reads

static void M_DECL textCallBack( void *data, int tag, char *output )

with

static void M_DECL textCallBack( void *data, int tag, const char *output )

If this reduces the errors to one (line 117 only), then we have a chance at correcting the error at line 117 too. If not, we will have to learn some C++ :wink:

1 Like

Dear Giovanni, I changed line 84 (now l. 85) from

static void M_DECL textCallBack( void *data, int tag, char *output )

to

static void M_DECL textCallBack( void *data, int tag, const char *output )

And, indeed, the number of errors is reduced to one. :relaxed:

make -f Makefile.9 all
gcc -L/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -Wl,-rpath,/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -lmaplec -I/Library/Frameworks/Maple.framework/Versions/2024/extern/include src.9/tm_maple_9.c -o /Users/tilda/.TeXmacs/bin/tm_maple_9

src.9/tm_maple_9.c:117:10: error: incompatible function pointer types initializing ‘void (*)(void *, intptr_t, const char )’ (aka 'void ()(void *, long, const char *)’) with an expression of type ‘void (void *, intptr_t, char *)’ (aka ‘void (void *, long, char *)’) [-Wincompatible-function-pointer-types]
errorCallBack,
^~~~~~~~~~~~~
1 error generated.

in line 90 (now 91), substitute arguments
void *data, M_INT offset, char *msg

with

void *data, M_INT offset, const char *msg

and let us see

1 Like

Dear Giovanni,

I applied your last substitutions, et voilà, tm_maple_9 compiles. :relaxed: A Maple session can be opened now. Judging from running some basic differential and integral calculus tasks, the plugin seems to be working fine.

Launching a Maple session however, issues the following notification:

/Users/tilda/.TeXmacs/plugins/maple/bin/tm_maple: line 25: [: bin.APPLE_ARM64_MACOS: integer expression expected

Wonder what this means now.:thinking:

Thank for your great help.

Cheers, Tilda

Giovanni, as we got the Maple plugin running I wonder if

  • I should write up the steps in a more orderly fashion, or do you think the procedure is clear enough?

  • Should we inform Joris that his plugin needs some modifications in tm_maple_9.c?

Cheers, Tilda

In my opinion yes to both. Maybe it would belong on the blog too, but I am not convinced—in addition, having the same thing in two places would mean that if you have to update it, you have to update it twice, so probably best here only.

I suggest a pinned wiki post; we can then add the link in the blog. Perhaps if we get the pinned posts to stay pinned for everyone (they are not now) we will make them more effective :slight_smile:

I’ve just posted a note on texmacs-users@texmacs.org. Let’s see if one of the developers reacts.

I’m more than willing to write s.th. more concise by the end of August. Maybe we could then discuss the details (scope, platform, design) in private email communication.

Cheers, Tilda

Ok, then till the end of August!

We received a patch from Jérôme Benoit, if you confirm that it works well, I’d like to help commit it to the SVN repo:

@darcy

I installed the new version of the Maple plugin from https://github.com/jgmbenoit/texmacs/tree/debian/1%2.1.4%2Bds-1/improve/plugins/maple/plugins/maple.

Next I ran the make-files as they were.

% make -f Makefile all
g++ src/tm_maple_5.cpp -o bin/tm_maple_5

worked fine. Yet tm_maple_9 is not compiled and I received a fatal error message on macOS 14.6.1.

% make -f Makefile.9 all
sed \
-e 's%${MAPLE}/$MAPLE_SYS_BIN/cmaple%/Users/tilda/.TeXmacs/bin/tm_maple_9%' \
-e 's%${MAPLE}/$MAPLE_SYS_BIN/maplew%/Users/tilda/.TeXmacs/bin/tm_maple_9%' \
/Library/Frameworks/Maple.framework/Versions/2024/bin/maple > /Users/tilda/.TeXmacs/bin/tm_maple_9.sh && chmod a+x /Users/tilda/.TeXmacs/bin/tm_maple_9.sh

gcc -L/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -Wl,-rpath,/Library/Frameworks/Maple.framework/Versions/2024/bin.APPLE_ARM64_MACOS -I/Library/Frameworks/Maple.framework/Versions/2024/extern/include src.9/tm_maple_9.c -o /Users/tilda/.TeXmacs/bin/tm_maple_9 -lmaplec

src.9/tm_maple_9.c:19:10: fatal error: ‘argz.h’ file not found
#include <argz.h>
**^~~~~~~~**
1 error generated.
make: *** [/Users/tilda/.TeXmacs/bin/tm_maple_9] Error 1

Wonder where the argz.h file is supposed to be from. Hope this helps,

cheers, Tilda

I’ve merged the pull request, see https://github.com/texmacs/texmacs/commit/273ae18ed559b63f7494234bbe2cded1095b1134

Your name as a reviewer is recorded in the commit message.

1 Like

@darcy Thanks, for uploading Jérôme’s overhauled maple plugin to https://github.com/texmacs/plugins. This upgrade is already a great, great improvement, even though Jérôme may have plans for further enhancements.

My post here as of Aug 11 has become obsolete. As the new plugin compiles out of the box and runs smoothly, I recommend every Maple users to upgrade to/use that version.

Cheers, Tilda

Getting the Maple plugin working – summary

In a nutshell, (@pireddag let me know if this suffices), to get to use Maple from within a TeXmacs session you need to do the following:

  • make sure that maple is in the path (c.f. post as of Aug 9)

  • Download Jérôme’s maple plugin from https://github.com/texmacs/plugins/tree/master/maple

  • copy it into TEXMACS_HOME_PATH/plugins/

  • change to TEXMACS_HOME_PATH/plugins/maple in order to compile tm_maple_9 by running

  • make -f Makefile.9 all

  • in TeXmacs, via the menu bar, do Tools->Update–>Plugins

and you are done.

Cheers, Tilda

1 Like

It seems sensible, but I will have a chance to test only the compilation; the menu entry appears (I think I recall correctly) only if one has Maple on their computer and I don’t.

By the way, what happened to the argz.h error?

I guess you’ll need to have Maple installed on your system to compile tm_maple_9. Jérôme made his first patch of tm_maple_9.c iso-conforming. For the details see https://github.com/texmacs/texmacs/pull/93.

I had not realized that things had gone forward on github. Very nice :slight_smile:
I also did not know, or I had forgotten, that there are different C standards.

Perhaps (but later) it is still worth to prepare a small user guide; I did not find one on github, I may have missed it