Search code examples
windows-7windowscygwin

Mimetex installation on Windows 7


I'm trying to install mimetex on Windows 7. To achieve this, I installed first cygwin on my machine, and then in the prompt window I typed:

gcc -DAA -DWINDOWS mimetex.c gifsave.c -lm -o mimetex.exe

in the right directory. In the prompt I read: enter image description here

but the exe was anyway created. When I tried to launch that exe, I saw this error:

enter image description here

Could it be some incompatibility with my Windows version? If yes, how can I solve?

Thanks in advance.


Solution

  • mimetex is using strcasestr that is not C standard and not available in every platform. Taking the example code from How does strcasestr in C work. Keep getting Error external symbol and putting in a strcasestr.c file we have

    $ cat strcasestr.c
    #include <stdlib.h>
    #include <ctype.h>
    
    char *strcasestr(const char *str, const char *pattern) {
        size_t i;
    
        if (!*pattern)
            return (char*)str;
    
        for (; *str; str++) {
            if (toupper(*str) == toupper(*pattern)) {
                for (i = 1;; i++) {
                    if (!pattern[i])
                        return (char*)str;
                    if (toupper(str[i]) != toupper(pattern[i]))
                        break;
                }
            }
        }
        return NULL;
    }
    

    and we can now compile with a lot of warning:

    $ x86_64-w64-mingw32-gcc -Wall  -DWINDOWS -DAA mimetex.c gifsave.c strcasestr.c -lm -o mimetex.cgi
    mimetex.c: In function ‘rastsmash’:
    mimetex.c:2384:26: warning: variable ‘ymin’ set but not used [-Wunused-but-set-variable]
    ....
    mimetex.c:16687:2: warning: variable ‘isqempty’ set but not used [-Wunused-but-set-variable]
      isqempty = 0,   /* true if query string empty */
      ^~~~~~~~
    $ ls -l mimetex.cgi
    -rwxr-xr-x 1 Marco Kein 1.8M Jan  1 08:31 mimetex.cgi
    

    Testing it in a CMD session, you can verify as suggested by the README that it is a stand alone windows program:

    >mimetex.cgi "x^2+y^2"
    +-----------------------------------------------------------------------+
    |mimeTeX vers 1.75, Copyright(c) 2002-2017, John Forkosh Associates, Inc|
    +-----------------------------------------------------------------------+
    | mimeTeX is free software, licensed to you under terms of the GNU/GPL, |
    |           and comes with absolutely no warranty whatsoever.           |
    |          See http://www.forkosh.com/mimetex.html for details.         |
    +-----------------------------------------------------------------------+
    Most recent revision: 10 June 2017
    
    Ascii dump of bitmap image...
    .................***......................................***...
    ................*...*....................................*...*..
    ...............**...**..................................**...**.
    ...............**....*..................................**....*.
    ....................**...........*...........................**.
    ....................**...........*...........................**.
    ....................*............*...........................*..
    ....**..****.......*.............*...........**.....*.......*...
    ...*..**...*......*..............*..........*.*.....*......*....
    ..*...*..........*...*...........*..........*.*.....*.....*...*.
    ..*...*.........*....*...........*..........*.*.....*....*....*.
    .....*.........*******....***************....*.....*....*******.
    .....*...........................*...........*.....*............
    .....*....*......................*...........*.....*............
    .....*....*......................*...........*....**............
    *...**...*.......................*...........*...**.............
    .***..***........................*............***.*.............
    .................................*................*.............
    .................................*...............*..............
    ............................................*...*...............
    .............................................***................