Thread: Static build of psql with readline support
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
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
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
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.
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
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
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
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
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
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
> 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
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.
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
> 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