Luajit2.0.4 Build錯誤

關於下載編譯構建Luajit-2.0.4請移步這裏,本文主要介紹一下在構建過程中遇到的奇葩問題。

從Windows上傳Luajit-2.0.4.zip到Linux服務器,在構建的時候可能會遇到如下的編譯錯誤:

In file included from lj_ffrecord.c:859:0:
lj_recdef.h:224:1: error: ‘recff_rawlen’ undeclared here (not in a function)
 recff_rawlen,
 ^
Makefile:645: recipe for target 'lj_ffrecord.o' failed

The root cause is in src/hostildvm_lib.c :

void emit_lib(BuildCtx *ctx)
{
    ......
    int ok = 1;
    if (!strcmp(buf, "#if LJ_52\n"))
      ok = LJ_52;
    else if (!strcmp(buf, "#if LJ_HASJIT\n"))
      ok = LJ_HASJIT;
    else if (!strcmp(buf, "#if LJ_HASFFI\n"))
      ok = LJ_HASFFI;
    ......
}

什麼原因?

因爲在Windows系統中,行尾結束符是"\r\n",所以!strcmp(buf,"#if LJ_52\n")就會返回false,!strcmp(buf, "#if LJ_HASJIT\n"將返回true,可以使用下面的命令轉換整個文件夾:

# cd luajit-2.0.4
# find . -type f -print0 | xargs -0 dos2unix
OK!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章