【问题标题】:Mimetex installation on Windows 7在 Windows 7 上安装 Mimetex
【发布时间】:2019-12-29 11:07:45
【问题描述】:

我正在尝试在 Windows 7 上安装 mimetex。为此,我首先在我的机器上安装了 cygwin,然后在提示窗口中输入:

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

在正确的目录中。 在提示中我读到:

但无论如何创建了 exe。当我尝试启动那个 exe 时,我看到了这个错误:

会不会是我的 Windows 版本不兼容?如果是,我该如何解决?

提前致谢。

【问题讨论】:

  • 您正在使用 cygwin 编译器,并且可能使用 -DWINDOWS 声明了一个 Windows 程序。要构建 Windows 程序,您需要使用交叉编译器 cygwin.com/packages/summary/mingw64-x86_64-gcc-core.html
  • 安装完这个包mingw之后,我要做什么呢?我不是很熟练,对不起。
  • 我读到mingw已经包含在cygwin的安装中了。是假的吗?
  • 该软件包包含在 cygwin 上运行但为 windows 构建的交叉编译器 x86_64-w64-mingw32-gcc.exe。 Cygwin 包含一些 mingw 编译器和库作为包;它不包含完整的 mingw 环境。在您的构建中使用x86_64-w64-mingw32-gcc insted 或gcc。我假设你有一个 64 位系统。
  • /tmp/cce6yBjW.o:mimetex.c:(.text+0x124bf): 引用未定义 "strcasestr" collect2: 错误: ld 返回 1 个退出状态

标签: windows-7 windows cygwin


【解决方案1】:

mimetex 使用的 strcasestr 不是 C 标准并且并非在每个平台上都可用。 以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 会话中对其进行测试,您可以按照 README 的建议验证它是一个独立的 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...
.................***......................................***...
................*...*....................................*...*..
...............**...**..................................**...**.
...............**....*..................................**....*.
....................**...........*...........................**.
....................**...........*...........................**.
....................*............*...........................*..
....**..****.......*.............*...........**.....*.......*...
...*..**...*......*..............*..........*.*.....*......*....
..*...*..........*...*...........*..........*.*.....*.....*...*.
..*...*.........*....*...........*..........*.*.....*....*....*.
.....*.........*******....***************....*.....*....*******.
.....*...........................*...........*.....*............
.....*....*......................*...........*.....*............
.....*....*......................*...........*....**............
*...**...*.......................*...........*...**.............
.***..***........................*............***.*.............
.................................*................*.............
.................................*...............*..............
............................................*...*...............
.............................................***................

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-07
    • 2011-03-29
    • 2016-10-27
    • 2013-10-30
    • 2011-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多