Coder Social home page Coder Social logo

configure fails to enable readline if ncurses is built with separate tinfo lib and "--as-needed" linker flag is used about asymptote HOT 5 CLOSED

tifv avatar tifv commented on July 20, 2024
configure fails to enable readline if ncurses is built with separate tinfo lib and "--as-needed" linker flag is used

from asymptote.

Comments (5)

johncbowman avatar johncbowman commented on July 20, 2024

Can you try out the latest git development source, which fixes some pkg-config issues?

from asymptote.

tifv avatar tifv commented on July 20, 2024

Yes, I have tried. It doesn't work.

It seems that for the ncurses check to succeed, -ltinfo should already be in $LIBS. But the tinfo check done with CHECK_LIB_STATIC autoconf macro, even successfull, doesn't append -ltinfo to $LIBS.

For example, replacing the line
CHECK_LIB_STATIC(tinfo,tinfo,tgetent,HAVE_LIBTINFO,AC_MSG_NOTICE([perhaps tgetent is in -lncurses]))
with
AC_CHECK_LIB(tinfo, tgetent)
on my system correctly prepends -ltinfo to $LIBS after the check and allows subsequent ncurses check to succeed.

As for pkg-config, it seems to work fine on my system:

$ pkg-config --libs tinfo
-ltinfo
$ pkg-config --libs ncurses
-lncurses -ltinfo

However, the CHECK_LIB_STATIC autoconf macro appends pkg-config output to $LDFLAGS during the check, but not to $LIBS. In linker arguments, $LDFLAGS goes before the conftest.cpp and $LIBS goes after it. Because --as-needed linker flag makes the order of linked libraries important, this results in a failed check.

from asymptote.

tifv avatar tifv commented on July 20, 2024

This is somewhat unfamiliar territory for me, but it seems that according to AC_CHECK_LIB documentation, any extra libraries required for correct linkage, such as produced by pkg-config --libs, should go in its fifth argument? Like this:

--- a/configure.ac
+++ b/configure.ac
@@ -344,7 +344,7 @@
 [
 LDFLAGS=$LDFLAGS_SAVE
 $5
-])
+],$PKG_FLAGS)
 ]
 else
 [
@@ -352,7 +352,7 @@
 $5
 ]
 fi
-)]
+,$PKG_FLAGS)]
 )
 
 if test "x$enable_readline" != "xno"; then

from asymptote.

johncbowman avatar johncbowman commented on July 20, 2024

Yes, that seems like a good solution. I think it is better than the one I came up:

--- a/configure.ac
+++ b/configure.ac
@@ -333,14 +333,24 @@ PKG_FLAGS=-l"$2"
 echo will try linking with $PKG_FLAGS
 fi
 LDFLAGS_SAVE=$LDFLAGS
-LDFLAGS="$LDFLAGS ""$STATIC ""$PKG_FLAGS ""$DYNAMIC "
-AC_CHECK_LIB($2,$3,AC_DEFINE($4,1,DEFINE_LIB($2)),
+LDFLAGS="$LDFLAGS "$STATIC"$PKG_FLAGS "$DYNAMIC
+AC_CHECK_LIB($2,$3,
+[
+LIBS=$LIBS$STATIC"$PKG_FLAGS "$DYNAMIC
+LDFLAGS=$LDFLAGS_SAVE
+AC_DEFINE($4,1,DEFINE_LIB($2))
+],
 if test "x$enable_static" = "xyes"; then
 [
 echo "Static library not found; will check for dynamic version"
 LDFLAGS="$LDFLAGS_SAVE ""$PKG_FLAGS "
 AS_UNSET([ac_cv_lib_$2_$3])
-AC_CHECK_LIB($2,$3,AC_DEFINE($4,1,DEFINE_LIB($2)),
+AC_CHECK_LIB($2,$3,
+[
+LIBS=$LIBS"$PKG_FLAGS "
+LDFLAGS=$LDFLAGS_SAVE
+AC_DEFINE($4,1,DEFINE_LIB($2))
+],
 [
 LDFLAGS=$LDFLAGS_SAVE
 $5

from asymptote.

johncbowman avatar johncbowman commented on July 20, 2024

Fixed in commit 99bd093.

from asymptote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.