[PPL-devel] Re: [SWIPL] Problem with plld?

Jan Wielemaker wielemak at science.uva.nl
Fri Nov 4 22:02:32 CET 2005


On Friday 04 November 2005 21:04, Roberto Bagnara wrote:
> I am having a problem with `plld' on one machine.
> The problem is there I get undefined references to symbols
> of the readline library, which is installed in the system:
>
> $ plld -cc gcc -c++ g++ -ld g++ -o ppl_pl ppl_swiprolog.o ppl_pl.o \
>          -L../../../src/.libs -lppl \
>          -L../../../Watchdog/src/.libs -lpwl \
>           -lm -lgmpxx -lgmp
> /usr/lib/pl-5.4.7/lib/i686-linux/libpl.a(pl-rl.o)(.text+0x33): In function
> `PL_install_readline': pl-rl.c: undefined reference to `rl_readline_name'
> /usr/lib/pl-5.4.7/lib/i686-linux/libpl.a(pl-rl.o)(.text+0x3d):pl-rl.c:
> undefined reference to `rl_attempted_completion_function'
> /usr/lib/pl-5.4.7/lib/i686-linux/libpl.a(pl-rl.o)(.text+0x47):pl-rl.c:
> undefined reference to `rl_basic_word_break_characters' ...
>
> If I add an explicit "-lreadline", then linking succeeds:
>
> $ plld -cc gcc -c++ g++ -ld g++ -o ppl_pl ppl_swiprolog.o ppl_pl.o \
>          -L../../../src/.libs -lppl \
>          -L../../../Watchdog/src/.libs -lpwl \
>          -lm -lgmpxx -lgmp -lreadline
> % halt
>
> The problem seems to be here:
>
> $ pl -dump-runtime-variables CC="gcc"; PLBASE="/usr/lib/pl-5.4.7";
> PLARCH="i686-linux";
> PLLIBS="-ldl /usr/lib/libreadline.a -lncurses -lncurses -lm -lrt ";
> PLLIB="-lpl";
> PLLDFLAGS="-export-dynamic  -O3 -pthread";
> PLSOEXT="so";
> PLVERSION="50407";
> PLSHARED="yes";
> PLTHREADS="yes";
>
> I have no idea why we have "/usr/lib/libreadline.a" instead of "-lreadline"
> in  `PLLIBS'.  In fact we get:

Because the RPM is built using the static version of libreadline to
avoid compatibility problems that were involved with this library for a
long time. Maybe these are sufficiently resolved to use the shared
object again these days.  I'm not sure.  If you build Prolog yourself
from the sources there should be no problem.

> So, either "-lreadline" should be used instead of "/usr/lib/libreadline.a",
> or "/usr/lib/libreadline.a" should be put after "-lpl" in the link command.
> In both cases, this would seem to be a bug in SWI-Prolog 5.4.7.

I modified plld to order .a files under the libraries rather than with the
object files.  This is only for the 5.5.x series.  For the 5.4.x series
I suggest adding -lreadline to the options.

	Cheers --- Jan

P.s.	It may be wise to consider turning the ppl extension into a 
	library that is dynamically loaded in SWI-Prolog.  No more need
	to recompile it for each new version of SWI-Prolog, easier to
	combine with other packages.




More information about the PPL-devel mailing list