C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-14-2010, 06:02 PM   #1
Registered User
 
Join Date: Mar 2010
Posts: 26
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,
HJoshy is offline   Reply With Quote
Reply

Tags
swi-prolog, vs2008 c++

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
coding and running application in C on mobile phone with Symbian johnyjj2 C Programming 0 11-22-2009 11:23 AM
Problem with com application amardon C++ Programming 3 10-06-2005 05:50 AM
Implementing portable user thread API to embedded microcontroller application draggy C Programming 4 07-10-2005 02:01 PM
MFC run application by clicking on file... dug Windows Programming 4 12-02-2004 04:33 AM


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


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22