Hi Simon! I have some experience with external predicates and embeddeding programs in Eclipse. You could try to do something like the code below ec_init(); //load the external predicate post_goal(term(EC_functor("load",1),"libexternalpredicates.so")); //the lib should be in LD_LIBRARY_PATH environment variable or in the same directory of the program //link the C function and the predicate. In my case the lib contain code to two predicates EC_atom method("method"); post_goal(term(EC_functor("external",2),method/4,"invoke_method")); EC_atom field("field"); post_goal(term(EC_functor("external",2),field/4,"access_field")); //call your program that make calls to "method" and "field" predicates .... I think this should work fine. Best regards, Christian ----- Original Message ----- From: "Simon Christensen" <christen@mail.csse.monash.edu.au> To: <eclipse-users@icparc.ic.ac.uk> Sent: Tuesday, August 09, 2005 9:21 AM Subject: [eclipse-users] External Predicates & Embedding > I have a problem related to external predicates. I have a predicate > written in C which I wish to be able to call within ECLiPSe. The problem > is that I am not in a standalone ECLiPSe environment, rather I am using > an embeddeding. > > My software is a simple visualisation application, built in C. I am > using an embedded ECLiPSe environment within it to add support for > various algorithms. The desired ECLiPSe program is in a file (I didn't > want to have to rewrite the whole thing by composing it using C > functions), and it is loaded into ECLiPSe by posting a compile goal. > > I have a function, p_change_node_colour() which is part of my C program > and I wish my script to be able to call it at key points in order to > synchronise the visualisation with the progress in ECLiPSe. The goal was > some level of animation, so I wanted to be able to see each update as it > happened. > > The problem that arises is that I can find no way of convincing ECLiPSe > to actually register my external predicate. The usual (and as far as I > can see, the only documented) way of using external predicates is to > compile the desired C functions into a shared library, load the library > into ECLiPSe and register the functions with ECLiPSe using external/2. > > Unfortunately, what I know of shared libraries leads me to the > conclusion that this isn't going to be possible for my application, as > the predicate in question needs to be able to communicate with other > parts of my program. I've tried using external/2 to link a predicate to > the desired function, however my ECLiPSe embedding doesn't like this, > coughing up an "External function does not exist" error. This is also > the case if I use external/1 in the script being included, then post the > external/2 call as a goal. > > I'm pretty sure I must be doing something wrong. If it's really not > possible to do what I'm trying to do, though, I'll have to look into > other strategies. > > Thanks in advance, > -- > Simon Christensen > _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/Received on Tue Aug 09 15:19:52 2005
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:39 PM GMT GMT