From: Ross Burton <ross.burton(a)arm.com>
-no-undefined was added to the libell.la LDFLAGS in commit 8391d72d,
back in 2012, as part of adding versioning. I believe there was some
confusion here as passing -no-undefined to libtool is different to
passing -no-undefined to the linker. The former changes libtool's
behaviour on Windows hosts related to static libraries, the latter will
warn if symbols are used but not defined.
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 4eb20c6..395edc3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,7 +138,7 @@ ell_libell_la_SOURCES = $(linux_headers) \
ell/gpio.c \
ell/path.c
-ell_libell_la_LDFLAGS = -no-undefined \
+ell_libell_la_LDFLAGS = -Wl,--no-undefined \
-Wl,--version-script=$(top_srcdir)/ell/ell.sym \
-version-info $(ELL_CURRENT):$(ELL_REVISION):$(ELL_AGE)
--
2.28.0
Show replies by date
From: Ossama Othman <ossama.othman(a)intel.com>
ELL requires the libdl library but does not add it to the LIBS build
variable. Add it to LIBS only if it is required to resolve dlopen()
and related functions at link-time so that the libdl dependency will
be embedded into the libell shared library binary:
Pre-change:
$ ldd ell/.libs/libell.so.0.0.2
linux-vdso.so.1 (0x00007ffec6fd2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb7db3bf000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb7db9f5000)
Post-change:
$ ldd ell/.libs/libell.so.0.0.2
linux-vdso.so.1 (0x00007fffb95d1000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f02bef2f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f02beb3e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f02bf378000)
This also obviates the need to explicitly add libdl to LDFLAGS for the
ELL plugin unit test.
Lastly, only add "-ldl" to the private library flags in ELL's
pkg-config file (ell.pc) since it is an ELL dependency that is only
exposed to the user if the platform in question doesn't support
inter-library dependencies, or when linking against the static ELL
library, e.g.:
$ pkg-config --libs ell
-L/usr/local/lib -lell
$ pkg-config --static --libs ell
-L/usr/local/lib -lell -ldl
---
Makefile.am | 2 +-
configure.ac | 2 +-
ell/ell.pc.in | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 395edc3..6c3b39f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -247,7 +247,7 @@ unit_test_io_LDADD = ell/libell-private.la
unit_test_ringbuf_LDADD = ell/libell-private.la
unit_test_plugin_LDFLAGS = -Wl,-export-dynamic
-unit_test_plugin_LDADD = ell/libell-private.la -ldl
+unit_test_plugin_LDADD = ell/libell-private.la
unit_test_checksum_LDADD = ell/libell-private.la
diff --git a/configure.ac b/configure.ac
index 490784f..a9d62ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,7 +108,7 @@ AC_CHECK_FUNC(timerfd_create, dummy=yes,
AC_CHECK_FUNC(epoll_create, dummy=yes,
AC_MSG_ERROR(epoll support is required))
-AC_CHECK_LIB(dl, dlopen, dummy=yes,
+AC_SEARCH_LIBS(dlopen, dl, dummy=yes,
AC_MSG_ERROR(dynamic linking loader is required))
AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
diff --git a/ell/ell.pc.in b/ell/ell.pc.in
index 4fc933b..d9aae8d 100644
--- a/ell/ell.pc.in
+++ b/ell/ell.pc.in
@@ -6,5 +6,6 @@ includedir=@includedir@
Name: ELL
Description: Embedded Linux library
Version: @VERSION@
-Libs: -L${libdir} -lell -ldl
+Libs: -L${libdir} -lell
+Libs.private: @LIBS@
Cflags: -I${includedir}
--
2.28.0