[PPL-devel] Re: [SWIPL] Is the functor `main' special? Is Cygwin special?
Jan Wielemaker
wielemaker at science.uva.nl
Thu Dec 23 14:51:07 CET 2004
On Thursday 23 December 2004 14:44, Roberto Bagnara wrote:
> Hi there,
>
> I am confused. Everything started when I tried to do un Cygwin what
> I usually do under GNU/Linux. I have a makefile rule that builds
> a stand-alone application as follows:
>
> pl_clpq$(EXEEXT): ppl_swiprolog.o pl_clpq.o pl_clpq.pl ../tests/clpq.pl
> plld -cc $(CC) -c++ $(CXX) -ld $(CXX) -pl-options,-g,main., -o $@
> $+ \ -L$(top_builddir)/src/.libs -lppl \
> -L$(top_builddir)/Watchdog/.libs -lpwl \
> @extra_libraries@
>
> Notice the option `-pl-options,-g,main.,', which, unless I am mistaken,
> means that main/0 is the goal to be executed at startup. (I am not sure
> the final dot and comma should be there, by the way.) While the
> application built that way runs happily under GNU/Linux, under Cygwin it
> dies
> because, while main/0 it is defined, main/1 is not. However,
> accorting to the `-pl-options' above, main/0 should be called,
> not main/1: I don't understand who is looking for main/1 and why.
> So I made a couple of experiment on GNU/Linux and the result is confusing:
>
> $ pl -g main
> ERROR: Undefined procedure: main/1
> ERROR: However, there are definitions for:
> ERROR: main/0
> $ pl -g main.
> ERROR: Undefined procedure: main/1
> ERROR: However, there are definitions for:
> ERROR: main/0
> $ pl -g foo
> ERROR: Prolog initialisation failed:
> ERROR: Undefined procedure: foo/0
> $ pl -g foo.
> ERROR: Prolog initialisation failed:
> ERROR: Undefined procedure: foo/0
>
> What is going on?
There is a library(main) which defines main/0, setup a sensible runtime
environment, picks the arguments and calls main/1 with the provided
arguments. This should not bother you if you nicely define main/0
yourself, but if it somehow picks up this definition, you loose.
Enjoy --- Jan
More information about the PPL-devel
mailing list