Is the functor `main' special? Is Cygwin special?

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? All the best,
Roberto

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

Jan Wielemaker wrote:
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.
Thanks Jan, and thanks also to Tom and Djame'.
Now I am less confused, but I still have a problem. So, I succeed obtaining pl_clpq.exe using this command, which seems to complete without error:
plld -cc gcc -c++ g++ -ld g++ -pl-options,-g,main -o pl_clpq.exe ppl_swiprolog.o pl_clpq.o \ ../../../../ppl-0.7pre10/interfaces/Prolog/SWI/pl_clpq.pl \ ../../../../ppl-0.7pre10/interfaces/Prolog/SWI/../tests/clpq.pl \ -L../../../src/.libs -lppl \ -L../../../Watchdog/.libs -lpwl \ -lm -lgmpxx -lgmp Info: resolving Parma_Polyhedra_Library::abandon_expensive_computations by linking to __imp___ZN23Parma_Polyhedra_Library30abandon_expensive_computationsE (auto-import) Info: resolving Parma_Polyhedra_Library::Coefficient_free_list_first by linking to __imp___ZN23Parma_Polyhedra_Library27Coefficient_free_list_firstE (auto-import) % ../../../../ppl-0.7pre10/interfaces/Prolog/SWI/pl_clpq.pl compiled 0.00 sec, 3,056 bytes % ../../../../ppl-0.7pre10/interfaces/Prolog/SWI/../tests/clpq.pl compiled 0.01 sec, 34,424 bytes % /usr/local/lib/pl-5.4.5/library/listing compiled into prolog_listing 0.01 sec, 14,356 bytes % /usr/local/lib/pl-5.4.5/library/edinburgh compiled into edinburgh 0.00 sec, 1,880 bytes % halt
And I am pretty sure the file `pl_clpq.pl' contains a definition for main/0 that is seen and works perfectly under GNU/Linux. Any idea why this seems to be not the case under Cygwin? Cheers,
Roberto
participants (2)
-
Jan Wielemaker
-
Roberto Bagnara