Lua 编译 GCC Linux Windows V0
可能严重过期以及误导,已使用MinGW,另见随笔,其余以后填坑。
- 之前是什么类似LuaRocks的工具集成生成了。>见后
- 对照如下include文件夹,不同版本中.h文件相同,.hpp不同。
文件夹..\lua-5.3.4_Sources\include、lua-5.3.4_Win32_dll15_lib、lua-5.3.4_Win32_mingw6_lib、lua53\include;
文件luaconf.h、lua.h、lauxlib.h、lualib.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):generic、linux。
generic: $(ALL)
linux:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
- 在srlua-102\Makefile中仅有Linux build,其中正有-ldl。
- 如在srlua-102\Makefile中的路径,需使用双引号,但注意不要嵌套了,只需要在最外层。
1 2 3 4 | LUA_TOPDIR= C:\ProgramFiles\lua\lua-5.3.4_Sources LUA_INCDIR= "$(LUA_TOPDIR)\include" LUA_LIBDIR= "$(LUA_TOPDIR)" INSTALL_DIR= ./ |
成功编译出srglue.exe、srlua.exe。
- lua-5.3.4_Sources\src中的make_uname.bat涉及make_uname(uname是linux的概念,包含mingw4、mingw4_64、cygw17)、tecmake(除包含mingw4、mingw4_64、cygw17,还包含vc10、vc10_64)。
- \lua-5.3.4_Sources\src\Makefile主要涉及linux、generic(对应ALL-all-ALL_T-LUA_A、LUA_T、LUAC_T,LUA_A-liblua.a(linux的静态库)、LUA_T-lua、LUAC_T-luac)
- 追查\lua-5.3.4_Sources\src\Makefile.tecmake,Windows_NT下对应tecmakewin.mak(否则对应tecmake.mak),WLUA=wula(貌似windows下)
- 除了all包含lualib、lua、luac、(windows平台相关的)wlua。有单独的、基础的lualib——TECMAKE_CMD(其余lua、luac、wlua都基于他)。
- 编译器主要使用了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的内容
1 2 3 4 5 | <strong>where< /strong > make make --version where gcc gcc --version pause |
- 更换编译工具后报错
除开错误,(第2行)是lua-5.3.4_Sources\Makefile进入了scr,使用其中的makefile(lua-5.3.4_Sources\src\Makefile)
从后往前,make、make[1]后者即嵌套的,所以Makefile:56、Makefile:63定位注意是哪层的makefile。
- 以上问题在于文件的路径为C:\ProgramFiles\MinGW\libexec\gcc\mingw32\9.2.0\liblto_plugin-0.dll,而我重命名mingw32-gcc-9.2.0.exe为gcc了。
- 对照MinGW64文件夹应该是自动匹配,但没见设置。
参考:gcc: fatal error: '-fuse-linker-plugin', but liblto_plugin-0.dll not found - Google 搜索
解决方法之一: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.exe、x86_64-w64-mingw32-gcc-9.2.0.exe(一个是cygwin,一个是mingw32根本就不是一个头)
搜ld.exe,仅mingw64\bin下有(MinGW无)。
- 使用mingw Installation Manager更新完后,正常了部分后cc1报错
(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\systreeLua 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.dllCompiler : 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.batConfiguring 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.luaCreating 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\?.dllNote 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. - 编译器可使用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.dll、ucrtbased.dll未找到——PATH NOT FOUND、NAME 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)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?