I'm getting this error when trying to require LuaSocket with Lua5.3
error loading module 'socket.core' from file
'/usr/local/lib/lua/5.3/socket/core.so':
/usr/local/lib/lua/5.3/socket/core.so: undefined symbol: luaL_openlib
Console Output with demonstration:
barreeeiroo#Telegram ~/mattata-ai> lua
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> local socket = require("socket.core")
> ^C⏎
barreeeiroo#Telegram ~/mattata-ai> lua5.3
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> local socket = require("socket.core")
error loading module 'socket.core' from file '/usr/local/lib/lua/5.3/socket/core.so':
/usr/local/lib/lua/5.3/socket/core.so: undefined symbol: luaL_openlib
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
> ^C⏎
barreeeiroo#Telegram ~/mattata-ai> readelf -a /usr/bin/lua | grep openlib
109: 0000000000018a70 163 FUNC GLOBAL DEFAULT 15 luaL_openlib##LUA_5.2
240: 0000000000018b20 117 FUNC GLOBAL DEFAULT 15 luaL_openlibs##LUA_5.2
barreeeiroo#Telegram ~/mattata-ai> readelf -a /usr/bin/lua5.3 | grep openlib
238: 000000000001b330 85 FUNC GLOBAL DEFAULT 15 luaL_openlibs##LUA_5.3
How can I make luaL_openlib to work with Lua5.3?
I faced the same issue and solved with this link: https://luarocks.org/
My problem is that I was using lua 5.3 and my luarocks was downloading modules for lua 5.1
Related
Trying to run dump(x) macro example from http://lua-users.org/wiki/LuaMacros :
$ lua -lmacro
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> __def 'dump(x) print(_STR(x).." = "..tostring(x))'
stdin:1: attempt to call global '__def' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: in ?
System: Cygwin x64.
Any ideas of what's wrong with __def? Thanks.
Run the following simple lua script but got error. I am running lua 5.2 on ubuntu.
local host, port = "127.0.0.1", 80
local socket = require("socket")
local tcp = assert(socket.tcp())
tcp:connect(host, port);
--note the newline below
tcp:send("GET / HTTP/1.1\r\n\r\n");
Here is the error:
~/learn/lua$ lua te.lua
lua: te.lua:2: module 'socket' not found:
no field package.preload['socket']
no file '/usr/local/share/lua/5.2/socket.lua'
no file '/usr/local/share/lua/5.2/socket/init.lua'
no file '/usr/local/lib/lua/5.2/socket.lua'
no file '/usr/local/lib/lua/5.2/socket/init.lua'
no file '/usr/share/lua/5.2/socket.lua'
no file '/usr/share/lua/5.2/socket/init.lua'
no file './socket.lua'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.2/socket.so'
no file '/usr/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
stack traceback:
[C]: in function 'require'
te.lua:2: in main chunk
[C]: in ?
Problem solved after installing the package manager luarocks and then socket package.
Here are the commands from the page
$ wget https://luarocks.org/releases/luarocks-2.4.1.tar.gz
$ tar zxpf luarocks-2.4.1.tar.gz
$ cd luarocks-2.4.1
$ ./configure; sudo make bootstrap
$ sudo luarocks install luasocket
$ lua
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> require "socket"
I tried this code :
assert(os.setlocale('fr_FR'))
print(12.34)
And it failed.
locale.lua
lua: locale.lua:1: assertion failed!
stack traceback:
[C]: in function 'assert'
locale.lua:1: in main chunk
[C]: in ?
On Ubuntu 14.04, lua -v
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
I'm trying to load the Lua Augeas bindings using the Lua 5.1 standalone interpreter:
$ lua5.1
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require 'augeas'
error loading module 'augeas' from file '/usr/lib/x86_64-linux-gnu/lua/5.1/augeas.so':
/usr/lib/x86_64-linux-gnu/lua/5.1/augeas.so: undefined symbol: aug_close
stack traceback:
[C]: ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
>
$ nm -D /usr/lib/x86_64-linux-gnu/lua/5.1/augeas.so | grep close
U aug_close
Is there something I'm doing wrong?
The lua-augeas library in Ubuntu is an old version which was not built with the necessary flags to make link it to the Augeas library.
$ lua -v -e "print(os.date('%l'))"
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
lua: (command line):1: bad argument #1 to 'date' (invalid conversion specifier '%l')
stack traceback:
[C]: in function 'date'
(command line):1: in main chunk
[C]: in
If so, where am I supposed to submit a bug report?
It's not a bug in Lua. os.date uses format, as described by strftime C function provided by your compiler (I mean the compiler that Lua was compiled with). It is known that some compilers (MSVC, for instance, which just outright crashes when provided with certain patterns) do not provide all patterns.