Skip to content

Error, "undefined symbol: lua_newuserdata" arise when I load luasql.postgres #180

@ytilimuh5306

Description

@ytilimuh5306

I need your help.

The OS is Rocky9, and installed postgresql-server, postgresql-server-devel

# cat /etc/rocky-release
Rocky Linux release 9.5 (Blue Onyx)

# dnf list --installed | grep postgresql
postgresql-server.x86_64                       13.20-1.el9_5                    @appstream               
postgresql-server-devel.x86_64                 13.20-1.el9_5                    @crb 

I built and installed Lua 5.2.4 from source.
I installed luasql-postgres with luarocks. But the error above is raised when I load it in the Lua script.
It's the same when I build it from the source

Here is the part of the code

# listener.lua
package.path = package.path .. ";/(source directory)/?.lua";
package.path = package.path .. ";/(source directory)/libs/?.lua";

local luasql = require "luasql.postgres"
~

The error message is below.

error loading module luasql.postgres from file /usr/local/lib/lua/5.2/luasql/postgres.so:
/usr/local/lib/lua/5.2/luasql/postgres.so: undefined symbol: lua_newuserdata
stack traceback:
    [C]: in ?
    [C]: in function require

I checked the dependencies of postgres.so, it seems that not all the symbols are exported from the Lua library.

[root@ik1-105-59335 luasql]# ldd -r /usr/lib/lua/5.2/luasql/postgres.so
        linux-vdso.so.1 (0x00007ffe1f52c000)
        libpq.so.private13-5 => /lib64/libpq.so.private13-5 (0x00007f953a319000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f953a000000)
        libssl.so.3 => /lib64/libssl.so.3 (0x00007f953a233000)
        libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007f9539a00000)
        libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f9539faa000)
        libldap.so.2 => /lib64/libldap.so.2 (0x00007f9539f43000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f953a37e000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f953a217000)
        libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f9539926000)
        libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f9539f2a000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f953a210000)
        libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f9539f19000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f953a207000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f9539912000)
        liblber.so.2 => /lib64/liblber.so.2 (0x00007f9539900000)
        libevent-2.1.so.7 => /lib64/libevent-2.1.so.7 (0x00007f95398a7000)
        libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007f9539887000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f9539858000)
        libcrypt.so.2 => /lib64/libcrypt.so.2 (0x00007f953981e000)
        libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f9539782000)
undefined symbol: lua_settop    (src/postgres.so)
undefined symbol: lua_toboolean (src/postgres.so)
undefined symbol: luaL_pushresultsize   (src/postgres.so)
undefined symbol: lua_touserdata        (src/postgres.so)
undefined symbol: luaL_setfuncs (src/postgres.so)
undefined symbol: luaL_argerror (src/postgres.so)
undefined symbol: lua_pushcclosure      (src/postgres.so)
undefined symbol: lua_tolstring (src/postgres.so)
undefined symbol: luaL_ref      (src/postgres.so)
undefined symbol: lua_createtable       (src/postgres.so)
undefined symbol: lua_rawset    (src/postgres.so)
undefined symbol: luaL_optlstring       (src/postgres.so)
undefined symbol: lua_rawgeti   (src/postgres.so)
undefined symbol: luaL_checklstring     (src/postgres.so)
undefined symbol: lua_pushvalue (src/postgres.so)
undefined symbol: lua_pushfstring       (src/postgres.so)
undefined symbol: lua_newuserdata       (src/postgres.so)
undefined symbol: lua_setmetatable      (src/postgres.so)
undefined symbol: lua_rawseti   (src/postgres.so)
undefined symbol: lua_pushnumber        (src/postgres.so)
undefined symbol: lua_settable  (src/postgres.so)
undefined symbol: lua_pushboolean       (src/postgres.so)
undefined symbol: luaL_checkstack       (src/postgres.so)
undefined symbol: luaL_buffinitsize     (src/postgres.so)
undefined symbol: luaL_checkudata       (src/postgres.so)
undefined symbol: lua_pushlstring       (src/postgres.so)
undefined symbol: luaL_error    (src/postgres.so)
undefined symbol: lua_isuserdata        (src/postgres.so)
undefined symbol: lua_pushnil   (src/postgres.so)
undefined symbol: lua_concat    (src/postgres.so)
undefined symbol: lua_type      (src/postgres.so)
undefined symbol: luaL_newmetatable     (src/postgres.so)
undefined symbol: luaL_unref    (src/postgres.so)
undefined symbol: lua_pushstring        (src/postgres.so)
undefined symbol: lua_getfield  (src/postgres.so)

I noticed after the installation that there was no liblua.so.
So, I built it as described in the #114

I copied liblua.so to /usr/lib64. also made the symbolic link /usr/lib64/liblua-5.2.so just in case, and reloaded ldconfig

# ls -la /usr/lib64/liblua*
lrwxrwxrwx 1 root root     20 May 14 12:12 /usr/lib64/liblua-5.2.so -> /usr/lib64/liblua.so
-rwxr-xr-x 1 root root 241336 May 14 12:08 /usr/lib64/liblua.so

# ldconfig -p | grep liblua
        liblua.so (libc6,x86-64) => /usr/local/lib/liblua.so
        liblua.so (libc6,x86-64) => /lib64/liblua.so
        liblua-5.2.so (libc6,x86-64) => /lib64/liblua-5.2.so

Again, I tried to install luasql-postgres using luarocks, and also built it from source.
But unfortunately the problem is still there and nothing has changed.

Could anyone share the idea for a solution?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions