Objectmix
Tags Register Mark Forums Read

SWI-Prolog as an embedded application in VS2008 C++ : PROLOG

This is a discussion on SWI-Prolog as an embedded application in VS2008 C++ within the PROLOG forums in Programming Languages category; 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 ); 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, _, _, _ ...


Object Mix > Programming Languages > PROLOG > SWI-Prolog as an embedded application in VS2008 C++

Reply

 

LinkBack Thread Tools
  #1  
Old 03-14-2010, 07:01 PM
Junior Member
 
Join Date: Mar 2010
Posts: 15
HJoshy is on a distinguished road
Default SWI-Prolog as an embedded application in VS2008 C++

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 );

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?

p.s. I am trying to use plld and avoid writing a separate dll.

Thank you,
Reply

Tags
swi-prolog, vs2008 c++

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Classes outside App_Code folder in website application (VS2008) usenet DOTNET 0 05-13-2009 07:45 PM
publish win forms application .net 3.0 vs2008 usenet CSharp 2 04-08-2008 02:31 AM
asp.net futures enabled web application in vs2008 usenet DOTNET 1 04-06-2008 08:04 AM
what is the differences/limitations between vs2003 and vs2008 fordeveloping mobile application usenet DOTNET 7 02-23-2008 09:17 AM
Application Config file not available for Class library in vs2008? usenet DOTNET 2 02-06-2008 04:50 AM


All times are GMT -5. The time now is 12:40 AM.

Managed by Infnx Pvt Ltd.