Windows 7上的Mimetex安装

时间:2019-12-29 11:07:45

标签: windows-7 windows cygwin

我正在尝试在Windows 7上安装mimetex。为此,我先在计算机上安装了cygwin,然后在提示符窗口中键入:

  

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

在正确的目录中。 在提示符下,我读到: enter image description here

但是仍然创建了exe。当我尝试启动该exe时,我看到了此错误:

enter image description here

可能与我的Windows版本不兼容吗?如果是,我该怎么解决?

谢谢。

1 个答案:

答案 0 :(得分:2)

mimetex使用的不是C标准的strcasestr,并非在所有平台上都可用。 从How does strcasestr in C work. Keep getting Error external symbol中获取示例代码 并放入一个strcasestr.c文件

$ 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;
}

现在我们可以编译出很多警告:

$ 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

在CMD会话中对其进行测试,可以按照自述文件的建议验证它是否是独立的Windows程序:

>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...
.................***......................................***...
................*...*....................................*...*..
...............**...**..................................**...**.
...............**....*..................................**....*.
....................**...........*...........................**.
....................**...........*...........................**.
....................*............*...........................*..
....**..****.......*.............*...........**.....*.......*...
...*..**...*......*..............*..........*.*.....*......*....
..*...*..........*...*...........*..........*.*.....*.....*...*.
..*...*.........*....*...........*..........*.*.....*....*....*.
.....*.........*******....***************....*.....*....*******.
.....*...........................*...........*.....*............
.....*....*......................*...........*.....*............
.....*....*......................*...........*....**............
*...**...*.......................*...........*...**.............
.***..***........................*............***.*.............
.................................*................*.............
.................................*...............*..............
............................................*...*...............
.............................................***................