Re: Frustrations/problems with GNU Prolog.
Daniel Diaz <[email protected]>
| Newsgroups | gmane.comp.gnu.prolog.general |
|---|---|
| Message-ID | <[email protected]> |
Le 11/07/2011 15:32, Steve641 a écrit : > I'm not sure how complex these questions are... I last wrote Prolog (using > Sicstus/SWI Prolog interpreters) in the early 1990s... I was rusty, but I > soon rediscovered lots of useful idioms. > > I've a script which I can consult from the command line of gprolog, and it > does what I want when I evaluate a predicate main/0. I'm having some > difficulties packaging my solution.... I'd like users to be blissfully > unaware that they're using a Prolog solution when they invoke it by name > from a shell prompt. > > The environment I'm using is Linux - the current Ubuntu Server distribution > for a 64-bit AMD system. > > $ uname -a > Linux server 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 > x86_64 x86_64 x86_64 GNU/Linux > $ > > I've installed the GNU prolog package (version 1.3.0 is the one in the > current Ubuntu Universe) and it's details are: > > $ apt-cache showpkg gprolog > Package: gprolog > Versions: > 1.3.0-6.1 > (/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_natty_universe_binary-amd64_Packages) > (/var/lib/dpkg/status) > Description Language: > File: > /var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_natty_universe_binary-amd64_Packages > MD5: bda800d61124d7f1de09fc061fac1d22 > Reverse Depends: > science-machine-learning,gprolog > prolog-el,gprolog > mace2,gprolog > laby,gprolog > laby,gprolog > gprolog-doc,gprolog 1.2.7 > Dependencies: > 1.3.0-6.1 - libc6 (2 2.11) gprolog-doc (0 (null)) > Provides: > 1.3.0-6.1 - > Reverse Provides: > $ > > When I try to compile my script to native, using glpc, I get unexpected > results. > > First, for any script, I get two (worrying-looking) warnings: > > $ gplc trivial.pl > /usr/bin/ld: Warning: alignment 8 of symbol `init_stream_supp' in > /usr/lib/gprolog-iso/libbips_pl.a(stream_supp.o) is smaller than 16 in > /usr/lib/gprolog-iso/libengine_pl.a(engine.o) > /usr/bin/ld: Warning: alignment 8 of symbol `fd_reset_solver' in > /usr/lib/gprolog-iso/libengine_fd.a(fd_inst.o) is smaller than 16 in > /usr/lib/gprolog-iso/libengine_pl.a(if_no_fd.o) > $ > > At first glance, these seem to be a problem with the Ubuntu packages for my > architecture. Is this a known problem? Are there any quick/easy > work-arounds? (I'd like a clean compile.) This is due to a gcc bug. This should not prevent gprolog from working. If you want a clean compile, get the last version. http://gprolog.org/gprolog-1.4.0.tar.gz You will have to compile and install it by yourself (until a ubuntu package is available). Follow the INSTALL file for this. Basically, cd src ./configure make make install > Next, for my script, I get a series of frustrating errors - all of this > form: > > /tmp/gplcUheTSf.o: In function `predicate(isValid/2)': > (.text+0x1ad): undefined reference to `predicate(validRanges/2)' > > Subsequent errors have a different location in .text - of course. In one > sense, this should not surprise me as there is no explicit definition for > validRanges/2 in my source code. My strategy was to require user input of > the desired ranges - then use asserta/1 to establish validRanges as a fact > before evaluating any predicate that needed it. This works fine from the > interactive prompt - but not when compiling to native. You have to inform the compiler validRanges/2 is a dynamic predicate. Add the following directive to your Prolog file: :- dynamic(validRanges/2). See: http://gprolog.org/manual/html_node/gprolog022.html#toc29 > be to pass the ranges recursively and explicitly to every predicate that > needs them... but this seems ugly. Are there any alternative strategies to > overcome this? > > Finally, I'm wondering if there is any support for passing command line > arguments to executables implemented using GNU prolog? In an ideal world, > I'd pass the desired ranges as command line arguments rather than require > them to be entered interactively. Any hints gratefully received. You can look at the following built-in predicates: argument_counter, argument_value, argument_list http://gprolog.org/manual/html_node/gprolog051.html#toc201 Daniel -- Ce message a ete verifie par MailScanner pour des virus ou des polluriels et rien de suspect n'a ete trouve.