[PPL-devel] Is Cygwin special?
Roberto Bagnara
bagnara at cs.unipr.it
Mon Jan 16 23:43:20 CET 2006
I have something that runs under GNU/Linux and does not run
under Cygwin. It all boils down to something very simple.
I have two files:
$ cat main.cc
#include <SWI-Prolog.h>
int
main(int, char** argv) {
char* pl_args[2];
pl_args[0] = argv[0];
pl_args[1] = 0;
if (!PL_initialise(1, pl_args))
PL_halt(1);
predicate_t pred = PL_predicate("mymain", 0, "user");
term_t h0 = PL_new_term_refs(0);
int ret_val = PL_call_predicate(0, PL_Q_NORMAL, pred, h0);
PL_halt(ret_val ? 0 : 1);
}
$ cat mymain.pl
mymain :-
write('mymain/0 called!'), nl.
I compile them under GNU/Linux:
$ g++ -I/usr/local/lib/pl-5.6.2/include -c main.cc
$ plld -v -cc gcc -c++ g++ -ld g++ -o test.exe main.o mymain.pl
eval `pl -dump-runtime-variables`
CC="gcc"
PLBASE="/usr/local/lib/pl-5.6.2"
PLARCH="i686-linux"
PLLIBS="-lgmp -ldl -lreadline -lncursesw -lm -lrt"
PLLIB="-lpl"
PLLDFLAGS="-export-dynamic -O3 -pthread"
PLSOEXT="so"
PLTHREADS="yes"
g++ -o test.exe -export-dynamic -O3 -pthread main.o -L/usr/local/lib/pl-5.6.2/lib/i686-linux -lpl -lgmp -ldl -lreadline -lncursesw -lm -lrt
pl -f none -F none -g true -t "consult(['mymain.pl']),qsave_program('pltmp-8678',[goal='\$welcome',toplevel=prolog,init_file=none])"
% mymain.pl compiled 0.00 sec, 2,004 bytes
% halt
cat pltmp-8678 >> test.exe
chmod 775 test.exe
rm pltmp-8678
I compile them in exactly the same way under Cygwin
(note: same version of SWI-Prolog, configured in the same way and
installed in the same place):
$ g++ -I/usr/local/lib/pl-5.6.2/include -c main.cc
$ plld -v -cc gcc -c++ g++ -ld g++ -o test.exe main.o mymain.pl
eval `pl -dump-runtime-variables`
% mymain.pl compiled 0.00 sec, 1,984 bytes
% halt
CC="gcc"
PLBASE="/usr/local/lib/pl-5.6.2"
PLARCH="i686-cygwin"
PLLIBS="-lgmp -lreadline -lncurses -lm -lpthread"
PLLIB="-lpl"
PLLDFLAGS="-export-dynamic -O3"
PLSOEXT="dll"
PLTHREADS="yes"
g++ -o test.exe -export-dynamic -O3 main.o -L/usr/local/lib/pl-5.6.2/lib/i686-cygwin -lpl -lgmp -lreadline -lncurses -lm -lpthread
pl -f none -F none -g true -t "consult(['mymain.pl']),qsave_program('pltmp-3416.exe',[goal='\$welcome',toplevel=prolog,init_file=none])"
cat pltmp-3416.exe >> test.exe
chmod 755 test.exe
rm pltmp-3416.exe
However, when I run the result under GNU/Linux I get:
$ ./test.exe
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.2)
Copyright (c) 1990-2005 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
mymain/0 called!
$
When I run under Cygwin I get:
$ ./test.exe
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.2)
Copyright (c) 1990-2005 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
ERROR: Undefined procedure: mymain/0
What am I missing?
All the best,
Roberto
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it
More information about the PPL-devel
mailing list