Thread

  1. Static build of psql with readline support

    Christopher Kings-Lynne <chriskl@familyhealth.com.au> — 2006-03-16T01:27:19Z

    Hi guys,
    
    I've been trying to build the cvs checkout of 8.1.3 on my freebsd 4.9 
    box with a STATIC psql utility.  I keep getting failures trying to hook 
    in libreadline I think:
    
    lreadline -lcrypt -lcompat -lm -lutil  -o psql
    /usr/lib/libreadline.a(terminal.o): In function `_rl_get_screen_size':
    terminal.o(.text+0x84): undefined reference to `tgetnum'
    terminal.o(.text+0xdd): undefined reference to `tgetnum'
    /usr/lib/libreadline.a(terminal.o): In function `rl_resize_terminal':
    terminal.o(.text+0x1ce): undefined reference to `tgetstr'
    /usr/lib/libreadline.a(terminal.o): In function `_rl_init_terminal_io':
    terminal.o(.text+0x2c6): undefined reference to `tgetent'
    terminal.o(.text+0x4a9): undefined reference to `tgetflag'
    ...more...
    
    It builds fine if I use --disable-readline, but other than that I simply 
    can't get it to build.  I've done gmake distclean, reconfigured, etc.
    
    How do I get this to work?  I've basically just added '-static' to the 
    psql Makefile, eg: 'psql: ${CC} -static ...'
    
    I can build static pg_dump and pg_dumpall just fine (they don't use 
    readline though of course.)
    
    Chris
    
    
    
  2. Re: Static build of psql with readline support

    Tom Lane <tgl@sss.pgh.pa.us> — 2006-03-16T02:55:36Z

    Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
    > I've been trying to build the cvs checkout of 8.1.3 on my freebsd 4.9 
    > box with a STATIC psql utility.  I keep getting failures trying to hook 
    > in libreadline I think:
    
    > lreadline -lcrypt -lcompat -lm -lutil  -o psql
    > /usr/lib/libreadline.a(terminal.o): In function `_rl_get_screen_size':
    > terminal.o(.text+0x84): undefined reference to `tgetnum'
    > terminal.o(.text+0xdd): undefined reference to `tgetnum'
    
    You seem to be missing the termcap or curses library in your link.
    readline requires whichever of those your platform has.
    
    			regards, tom lane
    
    
  3. Re: Static build of psql with readline support

    Mark Kirkwood <markir@paradise.net.nz> — 2006-03-16T03:09:53Z

    Christopher Kings-Lynne wrote:
    > Hi guys,
    > 
    > I've been trying to build the cvs checkout of 8.1.3 on my freebsd 4.9 
    > box with a STATIC psql utility.  I keep getting failures trying to hook 
    > in libreadline I think:
    > 
    > lreadline -lcrypt -lcompat -lm -lutil  -o psql
    > /usr/lib/libreadline.a(terminal.o): In function `_rl_get_screen_size':
    > terminal.o(.text+0x84): undefined reference to `tgetnum'
    > terminal.o(.text+0xdd): undefined reference to `tgetnum'
    > /usr/lib/libreadline.a(terminal.o): In function `rl_resize_terminal':
    > terminal.o(.text+0x1ce): undefined reference to `tgetstr'
    > /usr/lib/libreadline.a(terminal.o): In function `_rl_init_terminal_io':
    > terminal.o(.text+0x2c6): undefined reference to `tgetent'
    > terminal.o(.text+0x4a9): undefined reference to `tgetflag'
    > ...more...
    > 
    > It builds fine if I use --disable-readline, but other than that I simply 
    > can't get it to build.  I've done gmake distclean, reconfigured, etc.
    > 
    > How do I get this to work?  I've basically just added '-static' to the 
    > psql Makefile, eg: 'psql: ${CC} -static ...'
    > 
    > I can build static pg_dump and pg_dumpall just fine (they don't use 
    > readline though of course.)
    > 
    
    Add a -lcurses as well, as it seems that as soon as you force static, 
    libreadline needs to be told explicitly about libcurses. I'm on FreeBSD 
    6.0, but hopefully this is what is going on on 4.9 too.
    
    Cheers
    
    Mark
    
    
    
  4. Re: Static build of psql with readline support

    Martijn van Oosterhout <kleptog@svana.org> — 2006-03-16T08:53:41Z

    On Thu, Mar 16, 2006 at 04:09:53PM +1300, Mark Kirkwood wrote:
    > Christopher Kings-Lynne wrote:
    > >Hi guys,
    > >
    > >I've been trying to build the cvs checkout of 8.1.3 on my freebsd 4.9 
    > >box with a STATIC psql utility.  I keep getting failures trying to hook 
    > >in libreadline I think:
    
    <snip>
    
    > Add a -lcurses as well, as it seems that as soon as you force static, 
    > libreadline needs to be told explicitly about libcurses. I'm on FreeBSD 
    > 6.0, but hopefully this is what is going on on 4.9 too.
    
    Shared libraries can declare their own dependancies, static libs
    cannot. So when doing shared linking you only need to specify the libs
    you directly use. For static linking you need to list every library
    used by you and the libraries used by those libs etc, etc... The link
    lines for static linking are quite different from those for dynamic
    linking.
    
    This is incidently one of the reasons why people use libtool. If you
    specify static linking, libtool pulls up the .la files scattered across
    your disk to determine which libs are dependant on other libs. For
    dynamic linking the linker figures it out. For static it takes more
    legwork.
    
    Given the amount of legwork needed to make static linking work, is it
    worth supporting. readline is an easy case, it only depends on one
    other lib. libssl depends on 3 and libkrb5 on 5 other libs. For static
    linking we need to specify them all...
    
    To the GP, adding -lncurses (or rather the static equivalent) to your
    link line should solve it. But if you include any other libraries like
    ssl or kerberos be prepared to add a lot more.
    
    Have a nice day,
    -- 
    Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
    > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
    > tool for doing 5% of the work and then sitting around waiting for someone
    > else to do the other 95% so you can sue them.
    
  5. Re: Static build of psql with readline support

    Christopher Kings-Lynne <chris.kings-lynne@calorieking.com> — 2006-03-23T02:31:24Z

    > To the GP, adding -lncurses (or rather the static equivalent) to your
    > link line should solve it. But if you include any other libraries like
    > ssl or kerberos be prepared to add a lot more.
    
    With -lncurses or -lcurses I still can't get this to work.  I add it to 
    the ${CC} line, right?
    
    Chris
    
    
    
  6. Re: Static build of psql with readline support

    Mark Kirkwood <markir@paradise.net.nz> — 2006-03-23T02:43:09Z

    Christopher Kings-Lynne wrote:
    >> To the GP, adding -lncurses (or rather the static equivalent) to your
    >> link line should solve it. But if you include any other libraries like
    >> ssl or kerberos be prepared to add a lot more.
    > 
    > 
    > With -lncurses or -lcurses I still can't get this to work.  I add it to 
    > the ${CC} line, right?
    > 
    
    This is what I used (current 8.2 sources FreeBSD 6.0):
    
    
    *** Makefile.orig       Thu Mar 23 14:37:37 2006
    --- Makefile    Thu Mar 23 14:40:46 2006
    ***************
    *** 27,32 ****
    --- 27,34 ----
    
       FLEXFLAGS = -Cfe
    
    + CFLAGS += -static
    + LIBS += -lcurses
    
       all: submake-libpq submake-libpgport submake-backend psql
    
    
    
  7. Re: Static build of psql with readline support

    Mark Kirkwood <markir@paradise.net.nz> — 2006-03-23T03:39:45Z

    Andrew Dunstan wrote:
    > Mark Kirkwood said:
    > 
    >>Christopher Kings-Lynne wrote:
    >>
    >>>>To the GP, adding -lncurses (or rather the static equivalent) to your
    >>>>link line should solve it. But if you include any other libraries
    >>>>like ssl or kerberos be prepared to add a lot more.
    >>>
    >>>
    >>>With -lncurses or -lcurses I still can't get this to work.  I add it
    >>>to  the ${CC} line, right?
    >>>
    >>
    >>This is what I used (current 8.2 sources FreeBSD 6.0):
    >>
    >>
    >>*** Makefile.orig       Thu Mar 23 14:37:37 2006
    >>--- Makefile    Thu Mar 23 14:40:46 2006
    >>***************
    >>*** 27,32 ****
    >>--- 27,34 ----
    >>
    >>  FLEXFLAGS = -Cfe
    >>
    >>+ CFLAGS += -static
    >>+ LIBS += -lcurses
    >>
    >>  all: submake-libpq submake-libpgport submake-backend psql
    >>
    > 
    > 
    > That might work on FBSD but it doesn't work everywhere  - when I tried it on
    > Linux I got nasty link errors.
    > 
    
    It does for me (2.6.15-gentoo-r5) - note that my previous mail is way 
    too vague about which Makefile to patch (sorry): src/bin/psql/Makefile.
    
    Cheers
    
    Mark
    
    
    
    
    
  8. Re: Static build of psql with readline support

    Andrew Dunstan <andrew@dunslane.net> — 2006-03-23T03:41:47Z

    Mark Kirkwood said:
    > Christopher Kings-Lynne wrote:
    >>> To the GP, adding -lncurses (or rather the static equivalent) to your
    >>> link line should solve it. But if you include any other libraries
    >>> like ssl or kerberos be prepared to add a lot more.
    >>
    >>
    >> With -lncurses or -lcurses I still can't get this to work.  I add it
    >> to  the ${CC} line, right?
    >>
    >
    > This is what I used (current 8.2 sources FreeBSD 6.0):
    >
    >
    > *** Makefile.orig       Thu Mar 23 14:37:37 2006
    > --- Makefile    Thu Mar 23 14:40:46 2006
    > ***************
    > *** 27,32 ****
    > --- 27,34 ----
    >
    >   FLEXFLAGS = -Cfe
    >
    > + CFLAGS += -static
    > + LIBS += -lcurses
    >
    >   all: submake-libpq submake-libpgport submake-backend psql
    >
    
    That might work on FBSD but it doesn't work everywhere  - when I tried it on
    Linux I got nasty link errors.
    
    cheers
    
    andrew
    
    
    
    
  9. Re: Static build of psql with readline support

    Mark Kirkwood <markir@paradise.net.nz> — 2006-03-23T04:00:07Z

    Andrew Dunstan wrote:
    > Mark Kirkwood said:
    > 
    >>Andrew Dunstan wrote:
    >>
    >>>Mark Kirkwood said:
    >>>
    >>>
    >>>>Christopher Kings-Lynne wrote:
    >>>>
    >>>>
    >>>>>>To the GP, adding -lncurses (or rather the static equivalent) to
    >>>>>>your link line should solve it. But if you include any other
    >>>>>>libraries like ssl or kerberos be prepared to add a lot more.
    >>>>>
    >>>>>
    >>>>>With -lncurses or -lcurses I still can't get this to work.  I add it
    >>>>>to  the ${CC} line, right?
    >>>>>
    >>>>
    >>>>This is what I used (current 8.2 sources FreeBSD 6.0):
    >>>>
    >>>>
    >>>>*** Makefile.orig       Thu Mar 23 14:37:37 2006
    >>>>--- Makefile    Thu Mar 23 14:40:46 2006
    >>>>***************
    >>>>*** 27,32 ****
    >>>>--- 27,34 ----
    >>>>
    >>>> FLEXFLAGS = -Cfe
    >>>>
    >>>>+ CFLAGS += -static
    >>>>+ LIBS += -lcurses
    >>>>
    >>>> all: submake-libpq submake-libpgport submake-backend psql
    >>>>
    >>>
    >>>
    >>>That might work on FBSD but it doesn't work everywhere  - when I tried
    >>>it on Linux I got nasty link errors.
    >>>
    >>
    >>It does for me (2.6.15-gentoo-r5) - note that my previous mail is way
    >>too vague about which Makefile to patch (sorry): src/bin/psql/Makefile.
    > 
    > 
    > FC3:
    > 
    > /home/andrew/pglive/pgsql.plperl-pq/src/interfaces/libpq/ip.c:79: warning:
    > Using 'getaddrinfo' in statically linked applications requires at runtime the
    > shared libraries from the glibc version used for linking
    > collect2: ld returned 1 exit status
    > make: *** [psql] Error 1
    > 
    
    
    Is that after patching only the psql Makefile? Interesting - you 
    wouldn't think FC3 would be *that* different ....
    
    Cheers
    
    Mark
    
    
  10. Re: Static build of psql with readline support

    Andrew Dunstan <andrew@dunslane.net> — 2006-03-23T04:15:06Z

    Mark Kirkwood said:
    > Andrew Dunstan wrote:
    >> Mark Kirkwood said:
    >>
    >>>Christopher Kings-Lynne wrote:
    >>>
    >>>>>To the GP, adding -lncurses (or rather the static equivalent) to
    >>>>>your link line should solve it. But if you include any other
    >>>>>libraries like ssl or kerberos be prepared to add a lot more.
    >>>>
    >>>>
    >>>>With -lncurses or -lcurses I still can't get this to work.  I add it
    >>>>to  the ${CC} line, right?
    >>>>
    >>>
    >>>This is what I used (current 8.2 sources FreeBSD 6.0):
    >>>
    >>>
    >>>*** Makefile.orig       Thu Mar 23 14:37:37 2006
    >>>--- Makefile    Thu Mar 23 14:40:46 2006
    >>>***************
    >>>*** 27,32 ****
    >>>--- 27,34 ----
    >>>
    >>>  FLEXFLAGS = -Cfe
    >>>
    >>>+ CFLAGS += -static
    >>>+ LIBS += -lcurses
    >>>
    >>>  all: submake-libpq submake-libpgport submake-backend psql
    >>>
    >>
    >>
    >> That might work on FBSD but it doesn't work everywhere  - when I tried
    >> it on Linux I got nasty link errors.
    >>
    >
    > It does for me (2.6.15-gentoo-r5) - note that my previous mail is way
    > too vague about which Makefile to patch (sorry): src/bin/psql/Makefile.
    
    FC3:
    
    /home/andrew/pglive/pgsql.plperl-pq/src/interfaces/libpq/ip.c:79: warning:
    Using 'getaddrinfo' in statically linked applications requires at runtime the
    shared libraries from the glibc version used for linking
    collect2: ld returned 1 exit status
    make: *** [psql] Error 1
    
    
    
    cheers
    
    andrew
    
    
    
    
  11. Re: Static build of psql with readline support

    Andrew Dunstan <andrew@dunslane.net> — 2006-03-23T04:30:48Z

    Mark Kirkwood said:
    >>
    >>
    >> FC3:
    >>
    >> /home/andrew/pglive/pgsql.plperl-pq/src/interfaces/libpq/ip.c:79:
    >> warning: Using 'getaddrinfo' in statically linked applications
    >> requires at runtime the shared libraries from the glibc version used
    >> for linking
    >> collect2: ld returned 1 exit status
    >> make: *** [psql] Error 1
    >>
    >
    >
    > Is that after patching only the psql Makefile? Interesting - you
    > wouldn't think FC3 would be *that* different ....
    >
    
    Yes. I just patched that Makefile, and then in the psql directory did "make
    clean; make".
    
    cheers
    
    andrew
    
    
    
    
  12. Re: Static build of psql with readline support

    Martijn van Oosterhout <kleptog@svana.org> — 2006-03-23T19:50:18Z

    On Thu, Mar 23, 2006 at 10:31:24AM +0800, Christopher Kings-Lynne wrote:
    > >To the GP, adding -lncurses (or rather the static equivalent) to your
    > >link line should solve it. But if you include any other libraries like
    > >ssl or kerberos be prepared to add a lot more.
    > 
    > With -lncurses or -lcurses I still can't get this to work.  I add it to 
    > the ${CC} line, right?
    
    I'm not sure what controls it, but it's quite possible -lcurses tries
    to do a dynamic link again, you may need to specify the path to the .a
    file.
    
    Note, make sure you actually have the static version installed, not all
    distributions come with static versions these days...
    
    Have a nice day,
    -- 
    Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
    > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
    > tool for doing 5% of the work and then sitting around waiting for someone
    > else to do the other 95% so you can sue them.
    
  13. Re: Static build of psql with readline support

    Andrew Dunstan <andrew@dunslane.net> — 2006-03-23T20:25:08Z

    Christopher Kings-Lynne wrote:
    
    >> To the GP, adding -lncurses (or rather the static equivalent) to your
    >> link line should solve it. But if you include any other libraries like
    >> ssl or kerberos be prepared to add a lot more.
    >
    >
    > With -lncurses or -lcurses I still can't get this to work.  I add it 
    > to the ${CC} line, right?
    >
    
    
    What is the virtue of this in any case? I can see considerable use for a 
    statically linked pg_dump, to help with upgrading, but not too much for 
    statically linked anything else, especially since we are now pretty 
    relocatable on most platforms at least.
    
    cheers
    
    andrew
    
    
  14. Re: Static build of psql with readline support

    Christopher Kings-Lynne <chris.kings-lynne@calorieking.com> — 2006-03-24T01:31:15Z

    > What is the virtue of this in any case? I can see considerable use for a 
    > statically linked pg_dump, to help with upgrading, but not too much for 
    > statically linked anything else, especially since we are now pretty 
    > relocatable on most platforms at least.
    
    Upgraded db server to 8.1, but don't want to upgrade client library on 3 
    webservers to 8.1.  Reason being I'll have to end up rebuilding PHP and 
    more downtime and then new version of libtool, autoconf, etc. and 
    anything else FreeBSD ports decides it needs.  So, I just put static 
    versions of pg_dump, pg_dumpall and psql on the webservers in 
    /usr/local/bin so that those machines can still usefully talk to the db 
    server from the CLI.   In particular, I can restore dumps containing 
    dollar quotes, plus get new psql features and 8.1 dumps.
    
    Chris