I have a C++ application (prog.sln) which is my main program and I want to use Prolog as an embedded logic server (hanoi.pl)
int main(int argc, char** argv)
{
putenv( "SWI_HOME_DIR=C:\\Program Files\\pl" );
argv[0] = "libpl.dll";
argv[1] = "-x";
argv[2] = "hanoi.pl";
argv[3] = NULL;
PL_initialise(argc, argv);
{
fid_t fid = PL_open_foreign_frame();
predicate_t pred = PL_predicate( "hanoi", 1, "user" );
int rval = PL_call_predicate( NULL, PL_Q_NORMAL, pred, 3 );
qid_t qid = PL_open_query( NULL, PL_Q_NORMAL, pred, 3 );
while ( PL_next_solution(qid) ) return qid;
PL_close_query(qid);
PL_close_foreign_frame(fid);
system("PAUSE");
}
return 1;
system("PAUSE");
}
Here is my Prolog source code:
:- use_module( library(shlib) ).
hanoi( N ):-
move( N, left, center, right ).
move( 0, _, _, _ ):-
!.
move( N, A, B, C ):-
M is N-1,
move( M, A, C, B ),
inform( A, B ),
move( M, C, B, A ).
inform( X, Y ):-
write( 'move a disk from ' ),
write( X ),
write( ' to ' ),
write( Y ),
nl.
I type at the command:
plld -o hanoi prog.sln hanoi.pl
But it doesn't compile. When I run my C++ app, it says:
Undefined procedure: hanoi/1
What is missing/wrong in my code or at the prompt that prevents my C++ app from consulting Prolog?
Appreciate any help/pointer.