在 Windows 10 上使用 make 和 luarocks 安装 lua 的 CJSON 失败

我想在 Windows 10 (64 位) 上通过 luarocks 安装 CJSON,我已经做了这些事情:

尝试通过 make 安装:

  • 将这个 luajit 安装文件 放在路径为 "C:\torch" 中,并且手动设置所有以下路径变量 (参见issues)

    • Path = "C:\torch\bin;"%PATH%
    • LUA_CPATH="C:\torch\bin\?.dll;;"
    • LUA_DEV="C:\torch;"
    • LUA_PATH="C:\torch\lua\?;C:\torch\lua\?.lua;C:\torch\lua\?\init.lua;;"
  • 将这个版本的 lua-cjson-2.1.0 放在 "C:\Users\username\Desktop\lua-cjson-2.1.0" 目录下

  • 安装 make 版本 3.81,cmake 3.13.2,并将 "C:\MinGW\msys\1.0\bin\" 和 "C:\Program Files\CMake\bin\" 添加到路径变量中

  • 在 lua-cjson-2.1.0 的 Makefile 中取消注释 Windows(MingGW) 变量,并将 PREFIX = C:\torch\ 进行设置

  • 以管理员身份到达 "C:\Users\username\Desktop\lua-cjson-2.1.0" 目录

  • " make install" 输出如下:

cc -c -O3 -Wall -pedantic -DNDEBUG  -IC:\torch CJSON_CFLAGS =   -DDISABLE_INVALID_NUMBERS/include -fpic -o lua_cjson.o lua_cjson.c

make: cc: Command not found

make: *** [lua_cjson.o] Error 127`

尝试使用 luarocks 也不行:

  • 调用 ""C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64"

    • 然后按照 cjson-manual 中的说明调用 " luarocks make"
    • 这将输出以下内容:
cl /nologo /MD /O2 -c -Folua_cjson.obj -IC:/torch/include lua_cjson.c -DDISABLE_INVALID_NUMBERS lua_cjson.c

        cl /nologo /MD /O2 -c -Fostrbuf.obj -IC:/torch/include strbuf.c -DDISABLE_INVALID_NUMBERS strbuf.c

        strbuf.c(98): warning C4311: "type conversion": pointer truncation from "strbuf_t *" to "long"

        strbuf.c(172): warning C4311: "type conversion": pointer truncation from  "strbuf_t *" to"long"

        cl /nologo /MD /O2 -c -Fofpconv.obj -IC:/torch/include fpconv.c -DDISABLE_INVALID_NUMBERS fpconv.c

        link -dll -def:cjson.def -out:cjson.dll C:/torch/lib/libluajit.lib lua_cjson.obj strbuf.obj fpconv.obj

        Microsoft (R) Incremental Linker Version 14.10.25019.0

        Copyright (C) Microsoft Corporation.  All rights reserved.

        Bibliothek "cjson.lib" und Objekt "cjson.exp" werden erstellt.

        lua_cjson.obj : error LNK2019: Reference to unresolved external symbol "strncasecmp" in function "json_is_invalid_number".

cjson.dll : fatal error LNK1120: 1 nicht aufgelöste Externe

Error: Build error: Failed compiling module cjson.dll`

安装过程中出了什么问题?

点赞