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

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

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:

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
pword startTimes = ec_newvar();
int success;
pword *head;
pword *tail;

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_word startTimes = newvar();
post_goal(term(EC_functor("schedule",1), startTimes));

// 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?


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

This archive was generated by hypermail 2.3.0 : Wed Aug 21 2019 - 09:13:31 CEST