[eclipse-clp-users] C/C++ communication with ECLiPSe

From: Soheil Samii <sohsa_at_...107...>
Date: Tue, 10 Jun 2008 17:17:13 +0200
Hi!

I have a simple task scheduling problem for which I use ECLiPSe to find a 
solution. Basically, I generate the CLP formulation from a C++ program to an 
ECLiPSe file called scheduling.ecl (attached). 

I have tried to run it directly in ECLiPSe and it works fine:
[scheduling].
schedule(StartTimes).

The result (StartTimes) is a list of starting times for the tasks.

Then, I compile and run it from within a C++ program using the interfacing 
provided by the ECLiPSe C/C++ libraries. I have tried both the C approach and 
the C++ approach to get the result of the scheduling back to my C++ program 
and I have encountered problems in both cases, which I now describe:

* The C approach:

#include "eclipse.h"

// after the generation of scheduling.ecl
ec_init():
pword startTimes = ec_newvar();
int success;
pword *head;
pword *tail;

ec_post_goal(ec_term(ec_did("compile",1),ec_string("scheduling")));
ec_post_goal(ec_term(ec_did("schedule",1),startTimes));
ec_resume();
success = ec_get_list(startTimes,head,tail);

The problem here is that I get a segmentation fault, but clearly "startTimes" 
is a list of integer values. Does anybody know why I get a segfault?


* The C++ approach:

#include "eclipseclass.h"

// after the generation of scheduling.ecl
ec_init();
EC_word startTimes = newvar();
post_goal(term(EC_functor("compile",1),"scheduling"));
post_goal(term(EC_functor("schedule",1), startTimes));
ec_resume();

// here I intend to get the output with the EC_word class methods.

The problem here is that it doesn't compile. The error is that the compiler 
says that "newvar" is undefined, but I have checked in the header files and 
it should be defined. Does anybody know why this happens?

Thanks,
/Soheil




Received on Tue Jun 10 2008 - 08:23:50 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST