Jose's Blog

14.01.2021

Setting up Maple for startup code and for saving all data of the worksheet.

Filed under: Computer Math,Programming — Tags: — admin @ 15:53

This is about setting up maple so that:

  1. You can load your libraries from a customized location.
  2. You don’t have to execute the whole worksheet to get an old computed result.

I only know this for Windows, for linux this should be the same but probably easier. I had some problems in Maple for Windows because it changed the way it processes the .ini file without correctly documenting it. They kept an old documentation of the .ini file but the location of the .ini file should be corrected:

https://www.maplesoft.com/support/help/Maple/view.aspx?path=libname
https://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet/reference/initialization

In the past, in Windows, .ini was saved in %APPDATA%/Maple/<version>/maple.ini . This file still exist for newer maple version but it is not the same initialization file of the past (where you can write a startup code). The newer versions of Maple (I believe > version 16) uses this .ini file for the UI and not for startup code. However (undocumented) Maple will read another .ini file for startup, which unfortunately is also called maple.ini but located somewhere else. The startup code maple.ini file is now located in %USERPROFILE% (e.g. C:\Users\Jose). If this directory has no maple.ini, I suggest to create one.

Now if you want to have a startup code that:

  1. uses a customized location (for the sake of simplicity we want them to be in C:\my_libs) for libraries, put this in the init file:
    libname:="C:\\my_libs",libname:
    savelibname:="C:\\my_libs":
    
  2.  provides a procedure that saves all user variables from a worksheet (this is useful if you have something that computes for ages and whenever you open maple again you want to have the results). Put this in the maple.ini file:
    SaveAll := proc( fileName :: string )
    subs(_NAMES = anames(':-user'), proc() save _NAMES, fileName end proc)()
    end proc:
    

So now whenever I do some heavy computation in a worksheet before closing the worksheet I always type something like

SaveAll("C:/temp/maple.m");

And now when I open the worksheet again and I don’t want to re-execute the computation but still have the same variables I type
read("C:/temp/maple.m");

04.01.2021

xournal for win32

Filed under: Uncategorized — admin @ 09:38

Since the COVID pandemic I started to get more interested in Xournal. In fact, I was already interested in these kind of softwares but never really had the time to take them seriously. Now I actually need it for work. Most of my work are done via Zoom calls and Xournal doodles via screen sharing. There are many things to be wished in the xournal software and this is delivered in the all new Xournal++ software (for instance LaTeX annotation, drawing circles , splines and arrows turned out to be extremely useful esp. when annotating pdf of students). I looked a bit at the code of Xournal++ and I felt it would be a huge task if I want to try to understand it. It felt also more unstable than the original xournal (which is written in C rather than C++). So I thought I looked at the xournal code and just add the little things I am interested in  and maybe fix some bugs (I still use xournalpp for many things!). It will also help me improve my ability to port some originally developed Linux software into Windows.

My experience lies mostly in win32 development and so it was natural for me to look at xournal from this angle. xournal depends on libpoppler and libpoppler-glib. Both are notorious to be difficult to compile in windows. There is this MSys2 distribution that provided precompiled versions of libpoppler and libpoppler-glib, but I soon found out that the dependencies were quite heavy and I didn’t really needed the very latest version of libpoppler. I could have gotten away by finding another source of precompiled libpoppler library for windows (sourceforge has several of these) but all of them do not have libpoppler with glib wrapper and so I finally decided to do the dirty work myself and compile them myself. This is one of the hardest thing for me to compile that was originally developed in linux (I would put libflint as the hardest one!). libpoppler comes with cmake scripts, but they were so difficult to understand and the resulting makefile were also difficult to read. I also really wanted to compile this library in the most optimized way in windows (i.e. tweak the makefiles when possible). So I ended up doing the following:

  • Install GTK bundle for win32 (I got gtk+2.24.10)
  • Download libpoppler source (for me version 0.12.4 worked)
  • Write my own makefile for libpoppler-glib (I would not need libpoppler.dll in the end)
  • Download the dependencies: libgnomecanvas (I got the dev and bin for version 2.13), libart
  • Download precompiled libcairo for win32 (I go the src and bin of version 1.17.2)
  • Write my own makefile for xournal and finally built the whole thing with gcc and codeblocks.

You may need to edit directories in the makefiles and the package-config .pc files. My makefiles are usually located in a cbp directory created in the root directory of the source. My experience tells me: building a gtk project in windows is a nightmare if it is your first time (esp. if it is libpoppler-glib dependent).

Here is the xournal binary that I built that should be a little faster than the original distribution and has a little less dependencies.

I also make available libpoppler-glib (built together with libpoppler) precompiled win32 build.

Powered by WordPress