萝卜L

导航

Lua 编译 GCC Linux Windows V0

可能严重过期以及误导,已使用MinGW,另见随笔,其余以后填坑。

  • 之前是什么类似LuaRocks的工具集成生成了。>见后
  • 对照如下include文件夹,不同版本中.h文件相同,.hpp不同。
    文件夹..\lua-5.3.4_Sources\includelua-5.3.4_Win32_dll15_liblua-5.3.4_Win32_mingw6_liblua53\include
    文件luaconf.hlua.hlauxlib.hlualib.h
  • srlua-102\Makefile使用(唯一的)make Linux build
  • 使用lua-5.3.4_Sources对应的liblua.a,报错x86_64-w64-mingw32/bin/ld.exe: cannot find -ldl
  • \lua-5.3.4_Sources\src\Makefile中区分平台(PLANTS):genericlinux
generic: $(ALL)

linux:
    $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
  • srlua-102\Makefile中仅有Linux build,其中正有-ldl
  • 如在srlua-102\Makefile中的路径,需使用双引号,但注意不要嵌套了,只需要在最外层。
LUA_TOPDIR= C:\ProgramFiles\lua\lua-5.3.4_Sources
LUA_INCDIR= "$(LUA_TOPDIR)\include"
LUA_LIBDIR= "$(LUA_TOPDIR)"
INSTALL_DIR= ./

成功编译出srglue.exesrlua.exe

  • lua-5.3.4_Sources\src中的make_uname.bat涉及make_unameuname是linux的概念,包含mingw4mingw4_64cygw17)、tecmake(除包含mingw4mingw4_64cygw17,还包含vc10vc10_64)。
  • \lua-5.3.4_Sources\src\Makefile主要涉及linuxgeneric(对应ALL-all-ALL_T-LUA_ALUA_TLUAC_TLUA_A-liblua.a(linux的静态库)、LUA_T-luaLUAC_T-luac
  • 追查\lua-5.3.4_Sources\src\Makefile.tecmake,Windows_NT下对应tecmakewin.mak(否则对应tecmake.mak),WLUA=wula(貌似windows下)
  • 除了all包含lualiblualuac、(windows平台相关的)wlua。有单独的、基础的lualib——TECMAKE_CMD(其余lualuacwlua都基于他)。
  • 编译器主要使用了gcc、g++。
    其区别参见gcc和g++是什么关系? - 知乎 (zhihu.com)(未提及平台相关)
    参见:Welcome to MinGW.org (osdn.io)(对比CygWin,在POXIS上支持Windows的基础运行时库?)
  • 在环境变量中调整下顺序,先MinGW(后MinGW64)即可。
    然后make --version检查下。
    或者,用链接构造目录,在环境变量path中移动这两个目录的先后,实现切换32、64位。貌似不可以,还会使用到bin下的其他应用,貌似使用其相对位置确定plugin的位置。

  • check.cmd的内容
where make
make --version
where gcc
gcc --version
pause
  • 更换编译工具后报错

除开错误,(第2行)是lua-5.3.4_Sources\Makefile进入了scr,使用其中的makefile(lua-5.3.4_Sources\src\Makefile
从后往前,makemake[1]后者即嵌套的,所以Makefile:56Makefile:63定位注意是哪层的makefile。

解决方法之一:gcc -fno-use-linker-plugin,参见Using MinGW to compile C code, but error liblto_plugin-0.dll not found? - Stack Overflow

使用gcc插件路径会使用make中的版本号,故,不能make+gcc混搭。
否则出现C:\ProgramFiles\mingw64\bin\ld.exe: /cygdrive/c/ProgramFiles/cygwin64/bin/../lib/gcc/x86_64-pc-cygwin/10/cyglto_plugin.dll: error loading plugin:,而实际路径为C:\ProgramFiles\mingw64\libexec\gcc\x86_64-w64-mingw32\8.1.0\liblto_plugin-0.dll

10来自x86_64-pc-cygwin-gcc-10.exex86_64-w64-mingw32-gcc-9.2.0.exe(一个是cygwin,一个是mingw32根本就不是一个头)

ld.exe,仅mingw64\bin下有(MinGW无)。

  • 使用mingw Installation Manager更新完后,正常了部分后cc1报错MinGW bin libmpfr-6.dll(libmpfr-6.dll)
  • Luarocks,能搞清需要/依赖什么。

    ==========================
    == System check results ==
    ==========================

    Will configure LuaRocks with the following paths:
    LuaRocks : C:\Program Files (x86)\LuaRocks
    Config file : C:\Program Files (x86)\LuaRocks\config-5.3.lua
    Rocktree : D:\ProgramFiles\WorkPlace\systree

    Lua interpreter : D:\ProgramFiles\WorkPlace\lua53.exe
    binaries : D:\ProgramFiles\WorkPlace
    libraries : D:\ProgramFiles\Lua5.3-Source\lua-5.3.6_Win32_dll14_lib
    includes : D:\ProgramFiles\Lua5.3-Source\lua-5.3.6_Win32_dll14_lib\inclue
    architecture: x86
    binary link : lua53.lib with runtime MSVCRT.dll

    Compiler : Microsoft (make sure it is in your path before using LuaRocks


    Press <ENTER> to start installing, or press <CTRL>+<C> to abort. Use install /?
    for installation options.


    ============================
    == Installing LuaRocks... ==
    ============================


    Installing LuaRocks in C:\Program Files (x86)\LuaRocks...
    Created LuaRocks command: C:\Program Files (x86)\LuaRocks\luarocks.bat
    Created LuaRocks command: C:\Program Files (x86)\LuaRocks\luarocks-admin.bat

    Configuring LuaRocks...
    Created LuaRocks hardcoded settings file: C:\Program Files (x86)\LuaRocks\lua\larocks\core\hardcoded.lua
    Created LuaRocks config file: C:\Program Files (x86)\LuaRocks\config-5.3.lua

    Creating rocktrees...
    Created system rocktree : "D:\ProgramFiles\WorkPlace\systree"
    Created local user rocktree: "C:\Users\Administrator\AppData\Roaming\LuaRocks"

    Loading registry information for ".rockspec" files

    ============================
    == LuaRocks is installed! ==
    ============================


    You may want to add the following elements to your paths;
    Lua interpreter;
    PATH : D:\ProgramFiles\WorkPlace
    PATHEXT : .LUA
    LuaRocks;
    PATH : C:\Program Files (x86)\LuaRocks
    LUA_PATH : C:\Program Files (x86)\LuaRocks\lua\?.lua;C:\Program Files (x86)\LuaRocks\lua\?\init.lua
    Local user rocktree (Note: %APPDATA% is user dependent);
    PATH : %APPDATA%\LuaRocks\bin
    LUA_PATH : %APPDATA%\LuaRocks\share\lua\5.3\?.lua;%APPDATA%\LuaRocks\share\lua\5.3\?\init.lua
    LUA_CPATH: %APPDATA%\LuaRocks\lib\lua\5.3\?.dll
    System rocktree
    PATH : D:\ProgramFiles\WorkPlace\systree\bin
    LUA_PATH : D:\ProgramFiles\WorkPlace\systree\share\lua\5.3\?.lua;D:\ProgramFies\WorkPlace\systree\share\lua\5.3\?\init.lua
    LUA_CPATH: D:\ProgramFiles\WorkPlace\systree\lib\lua\5.3\?.dll

    Note that the %APPDATA% element in the paths above is user specific and it MUST be replaced by its actual value.
    For the current user that value is: C:\Users\Administrator\AppData\Roaming.

    另使用到LuaBinaries download | SourceForge.net

  • 编译器可使用Microsoft Visual C++ Build Tools,已打包安装,参见:
    Microsoft Visual C++ Build Tools.exe安装包损坏 - 追风赶月的少年 - 博客园 (cnblogs.com)
    如何下载visual c++ build tools的离线完整版_u013085021的博客-CSDN博客_visualcppbuildtools_full.exe
  • 学习 记录:Windows下编译luaiconv为DLL拓展_SoraYuki的博客-CSDN博客
    windows下lua iconv,含各阶段的编译方法及最终结果
    luaiconv跳坑记_flyliying的博客-CSDN博客
  • 续上,对iconv.dll,lua.exe/lua53.exe,找不到指定的模块。用ProcessMonitor发现VCRUNTIME140D.dllucrtbased.dll未找到——PATH NOT FOUNDNAME NOT FOUND
    luaiconv.dll,依赖LuaDll_x86.dll(无)、VCRUNTIME140.dll(有)。
  • 以上VCRUNTIME14D.dll是Visual C++ Redistributable for Visual Studio 2015(Download Visual C++ Redistributable for Visual Studio 2015 from Official Microsoft Download Center
    但笔记本上有VCRUNTIME140.dll(缺少D)。
    D表示Debug,见VS在debug时找不到vcruntime140d.dll - 哔哩哔哩 (bilibili.com)
    从网上补全了此两个dll,用lua(51)正常运行。(用Lua53会卡在require处)
  • 避免尝试跨平台的编译了..
    windows编译libiconv和lua-iconv模块 - 简书 (jianshu.com)

posted on 2021-07-23 21:35  萝卜L  阅读(521)  评论(0编辑  收藏  举报