Skip to content

How to resolve "undefined symbol: lua_resty_ffi_init" #8

@vikirj

Description

@vikirj

I have installed lua-resty-ffi to enable HTTP/3 support by following these steps:

luarocks config variables.OR_SRC /tmp/tmp.Z2UhJbO1Si/openresty-1.21.4.1
luarocks install lua-resty-ffi

This successfully generated the libresty_ffi.so file at:

/usr/local/lib/lua/5.1/libresty_ffi.so

However, when sending a request, I encountered the following error in the logs:

2025/09/09 11:53:31 [info] 3054922#0: *19 client closed connection while waiting for request, client: 192.168.1.1, server: 0.0.0.0:443
2025/09/09 11:53:31 [debug] 3054918#0: *18 [lua] access_by_lua(nginx.conf:56):2: Route: /test_route Client IP: 192.168.1.1
2025/09/09 11:53:31 [info] 3054918#0: *18 [lua] test.lua:115: TestRoute(): 192.168.1.2:5000, client: 192.168.1.1, server: 127.0.0.1, request: "GET /test_route HTTP/1.1", host: "test.duckdns.org"
2025/09/09 11:53:31 [debug] 3054918#0: *18 [lua] test.lua:117: TestRoute(): Resolve request url: https://192.168.1.2:5000/test_route
2025/09/09 11:53:31 [error] 3054918#0: *18 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/resty_ffi.lua:110: /usr/local/lib/lua/5.1/libresty_ffi.so: undefined symbol: lua_resty_ffi_init
stack traceback:
coroutine 0:
	[C]: in function 'require'
	.../openresty/test.lua:125: in function 'TestRoute'
	access_by_lua(nginx.conf:56):3: in main chunk, client: 192.168.1.1, server: 127.0.0.1, request: "GET /test_route HTTP/1.1", host: "test.duckdns.org"

To debug this, I inspected the shared library with the command:

nm -D libresty_ffi.so
The output indicates that the lua_resty_ffi_init symbol is missing:

000000000000150e T build_id_data
00000000000013e9 T build_id_find_nhdr_by_name
000000000000145a T build_id_find_nhdr_by_symbol
00000000000014f9 T build_id_length
                 w __cxa_finalize@GLIBC_2.2.5
                 U dladdr@GLIBC_2.34
                 U dl_iterate_phdr@GLIBC_2.2.5
                 w __gmon_start__
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 U memcmp@GLIBC_2.2.5
                 U __stack_chk_fail@GLIBC_2.4
                 U strcmp@GLIBC_2.2.5

As you can see, the function lua_resty_ffi_init is not defined in the shared object file.

How can I resolve the undefined symbol: lua_resty_ffi_init error and properly load libresty_ffi.so ? Anything I missed during installation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions