1 From 62ede7482da15d276b880f6d8540dce400dc50a7 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Thu, 26 Nov 2015 15:59:07 +0100
4 Subject: [PATCH] configure: fix static linking with readline
6 When static linking is used, the order of the libraries is important,
7 and the libraries using a symbol from another library should be listed
8 *before* the library providing that symbol (see
9 http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking)
12 When vtysh is linked statically, the command line contains "-lcurses
13 -lreadline", which causes a build failure due to unresolved
14 symbols. This is because readline is using symbols from the curses
15 library: the order should be the opposite.
17 This patch fixes that problem by putting the -lreadline at the
18 beginning of the LIBREADLINE variable calcualted by the configure
21 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
24 1 file changed, 1 insertion(+), 1 deletion(-)
26 diff --git a/configure.ac b/configure.ac
27 index 3003e62..290953d 100755
30 @@ -652,7 +652,7 @@ dnl [TODO] on Linux, and in [TODO] on Solaris.
34 - AC_CHECK_LIB(readline, main, LIBREADLINE="$LIBREADLINE -lreadline",,
35 + AC_CHECK_LIB(readline, main, LIBREADLINE="-lreadline $LIBREADLINE",,
37 if test $ac_cv_lib_readline_main = no; then
38 AC_MSG_ERROR([vtysh needs libreadline but was not found and usable on your system.])