MacOS 使用 luarocks+wrk+luajit

MacOS 使用 luarocks+wrk+luajit

luarocks 默认使用的是 lua 5.4 版本,一些工具,例如 wrk 使用的 lua 5.1,那么 luarocks 在安装依赖的时候就需要指定 lua 5.1。

luarocks config 配置 lua 5.1

请确保已经安装了 lua5.1 或者 luajit,本处使用 luajit。

shell 复制代码
luarocks config lua_dir /opt/homebrew/opt/luajit
text 复制代码
Lua version will default to 5.1 in /opt/homebrew/etc/luarocks
Wrote
	lua_version = "5.1"
to
	/opt/homebrew/etc/luarocks/config-5.1.lua
qyvlik@qyvlikdeMacBook-Pro luarocks % luarocks config lua_dir /opt/homebrew/opt/luajit
Wrote
	variables.LUA = "/opt/homebrew/opt/luajit/bin/luajit"
	variables.LUA_BINDIR = "/opt/homebrew/opt/luajit/bin"
	variables.LUA_DIR = "/opt/homebrew/opt/luajit"
	variables.LUA_INCDIR = "/opt/homebrew/opt/luajit/include/luajit-2.1"
	variables.LUA_LIBDIR = "/opt/homebrew/opt/luajit/lib"
to
	/opt/homebrew/etc/luarocks/config-5.1.lua

写入文件的位置 /opt/homebrew/etc/luarocks/config-5.1.lua,内容如下:

lua 复制代码
-- LuaRocks configuration

rocks_trees = {
   { name = "user", root = home .. "/.luarocks" };
   { name = "system", root = "/opt/homebrew" };
}
variables = {
   LUA_DIR = "/opt/homebrew/opt/luajit";
   LUA_BINDIR = "/opt/homebrew/opt/luajit/bin";
   LUA_VERSION = "5.1";
   LUA = "/opt/homebrew/opt/luajit/bin/luajit";
}
shell 复制代码
luarocks config lua_version 5.1
text 复制代码
Wrote
	lua_version = "5.1"
to
	/opt/homebrew/etc/luarocks/config-5.1.lua

写入文件的位置 /opt/homebrew/etc/luarocks/default-lua-version.lua,内容如下:

lua 复制代码
return "5.1"

luarocks install snowflake

如果需要使用代理安装,请在执行如下命令,请确保有对应的 proxy 服务在运行。

shell 复制代码
export all_proxy=http://127.0.0.1:3128

安装需要指定 --lua-version=5.1

shell 复制代码
luarocks install snowflake --lua-version=5.1

没有指定 lua-version

text 复制代码
admin@localhost% luarocks install snowflake
Installing https://luarocks.org/snowflake-1.0-1.rockspec
Cloning into 'lua-snowflake'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 21 (delta 3), reused 2 (delta 2), pack-reused 13 (from 1)
Receiving objects: 100% (21/21), 8.39 KiB | 8.39 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Note: switching to 'e4f3008828ea83ff1ba6651a766a349d449cee44'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false



snowflake 1.0-1 depends on lua >= 5.1 (5.4-1 provided by VM: success)
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.4 -c src/main.c -o src/main.o
src/main.c:47:23: error: call to undeclared function 'luaL_checkint'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   47 |     g_datacenter_id = luaL_checkint(L, 1);
      |                       ^
src/main.c:47:23: note: did you mean 'luaL_checkany'?
/opt/homebrew/opt/lua/include/lua5.4/lauxlib.h:68:18: note: 'luaL_checkany' declared here
   68 | LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
      |                  ^
1 error generated.

Error: Build error: Failed compiling object src/main.o

指定 lua-version

text 复制代码
admin@localhost% luarocks install snowflake --lua-version=5.1
Installing https://luarocks.org/snowflake-1.0-1.rockspec
Cloning into 'lua-snowflake'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 21 (delta 3), reused 2 (delta 2), pack-reused 13 (from 1)
Receiving objects: 100% (21/21), 8.39 KiB | 4.19 MiB/s, done.
Resolving deltas: 100% (3/3), done.
Note: switching to 'e4f3008828ea83ff1ba6651a766a349d449cee44'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false



snowflake 1.0-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/luajit/include/luajit-2.1 -c src/main.c -o src/main.o
src/main.c:8:9: warning: 'luaL_newlib' macro redefined [-Wmacro-redefined]
    8 | #define luaL_newlib(L, l) ( lua_newtable( L ), luaL_register( L, NULL, l ) )
      |         ^
/opt/homebrew/opt/luajit/include/luajit-2.1/lauxlib.h:125:9: note: previous definition is here
  125 | #define luaL_newlib(L, l)       (luaL_newlibtable(L, l), luaL_setfuncs(L, l, 0))
      |         ^
1 warning generated.
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc  -bundle -undefined dynamic_lookup -all_load -o /var/folders/lt/g2t6nfq96cs0lwt4nl86gys40000gn/T/luarocks_build-snowflake-1.0-1-5295760/snowflake.so src/main.o
No existing manifest. Attempting to rebuild...
snowflake 1.0-1 is now installed in /opt/homebrew (license: MIT)

ref

相关推荐
白玉cfc17 小时前
【iOS】多线程基础
macos·ios
2501_9151063219 小时前
游戏上架 App Store 的技术流程解析 从构建到审核的全流程指南
游戏·macos·ios·小程序·uni-app·cocoa·iphone
laocaibulao21 小时前
mac电脑brew update很慢咋办?
macos
心灵宝贝21 小时前
XMind for Mac v24.01.dmg 安装教程(Mac思维导图软件下载安装步骤)
macos·xmind
醇氧1 天前
Mac 安装 Docker Desktop
macos·docker·容器
神秘人-解说1 天前
在Mac上安装Windows 11/10双系统(M1/M2/Intel通用)
windows·macos·mac安装双系统·mac安装虚拟机·mac安装windows
知难行难1 天前
macOS配置Apocrita及ssh访问及获取GPU权限
运维·macos·ssh
游戏开发爱好者82 天前
Mac 抓包软件怎么选?从 HTTPS 调试、TCP 数据流分析到多工具协同的完整抓包方案
tcp/ip·macos·ios·小程序·https·uni-app·iphone
马拉萨的春天2 天前
iOS中广告SDK如何判断一个广告是否真实展示
macos·ios·cocoa
心灵宝贝2 天前
Mac 安装 JDK 8u281(JDK-8u281-1.dmg)详细步骤(附安装包)
java·macos·intellij-idea