Hello Lua maintainers,
While running unit tests in a glibc-based environment, I encountered a runtime
issue when loading the shared library liblua.so.5.1.5:
Failed to load lib /lib/liblua.so.5.1.5: undefined symbol: sinhThis happens because
liblua.so is under-linked: it does not explicitly declare
libm.so as a dependency in its
DT_NEEDED entries.
On glibc-based systems, standard math functions like sinh, cos, etc.,
are provided by libm, which is a separate shared library.
Without declaring libm as a dependency, loading liblua.so directly will fail
unless the consumer explicitly links against
-lm, which incorrectly shifts
responsibility for resolving these symbols from the library itself to its users.
Linking
-lm in downstream applications or test binaries masks the issue but is not a proper solution:
the shared library itself should declare all libraries required to resolve its
own symbols.Proposed Fix:Update the shared library link stage for liblua.so to explicitly link against libm (-lm).
This ensures that:
1. All direct dependencies of liblua are correctly declared.
2. liblua.so can be safely loaded on glibc-based systems without requiring consumers
to add -lm.
This change has been verified on a glibc system and resolves the undefined 'sinh' symbol.Patch:---
diff --git a/Makefile b/Makefile
index 7fea77e5b1..14aa34ba52 100644
--- a/Makefile
+++ b/Makefile
@@ -94,6 +94,7 @@ define Build/Configure
TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
+TARGET_LDFLAGS += -lm
---
Signed-off-by: Mabrouka <
mabrouka.ben...@softathome.com>