❦ 13 juillet 2015 19:58 +0200, Vincent Bernat <ber...@luffy.cx> :
> I suppose that either -ldl could be added to OPTIONS_LDFLAGS append, > like this is done for -lm. Or USE_DL section could be moved towards the > end. I think the first solution is better since libdl seems to be a > dependency of lua. > > Note that this is not an Ubuntu-specific but they enforce --as-needed by > default directly in the linker. Here is a proposition. An alternative would be to move the ifneq ($(USE_DL),) section at the end of the Makefile.
>From 698116edb22ce8b56db3669314d50faf88daf77e Mon Sep 17 00:00:00 2001 From: Vincent Bernat <vinc...@bernat.im> Date: Thu, 16 Jul 2015 20:52:51 +0200 Subject: [PATCH] BUILD: link with libdl if needed for Lua support On platforms where the dl*() functions are not part of the libc, a program linking Lua also needs to link to libdl. Moreover, on platforms using a gold linker with the --as-needed flag, the libdl library needs to be linked after linking Lua, otherwise, it won't be marked as needed and will be discarded and its symbols won't be present at the end of the linking phase. Ubuntu enables the --as-needed flag by default. Other distributions may advertise its use, like Gentoo. --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 6ab7d5469d90..a1383a38c539 100644 --- a/Makefile +++ b/Makefile @@ -606,6 +606,9 @@ endif endif OPTIONS_LDFLAGS += $(LUA_LD_FLAGS) -l$(LUA_LIB_NAME) -lm +ifneq ($(USE_DL),) +OPTIONS_LDFLAGS += -ldl +endif OPTIONS_OBJS += src/hlua.o endif -- 2.1.4
-- Keep it right when you make it faster. - The Elements of Programming Style (Kernighan & Plauger)