[eclipse-clp-users] Probably a simple question to answer about using external C++ code for predicates

From: Yvon Muc <yvon.muc_at_...335...>
Date: Thu, 17 May 2012 22:23:04 -0400
Greetings,

I've simplified my problem down to the code at the end of my message.  
Basically it seems like as soon as I try to include any C++ 
headers/libraries/code, the prolog file will no longer compile, complaining:

cvode_interface.so: undefined symbol: _ZSt4cout
problem while trying to load a shared library in load("cvode_interface.so")
ERROR: heart.pl:9:
   Query exited (abort): :- load(cvode_interface.so)
External function does not exist in external_(t / 1, p_interfacetest, 
eclipse)
ERROR: heart.pl:11:
   Query exited (abort): :- external(t / 1, p_interfacetest)

whereas if I comment out the 3 lines of C++ hello world, and uncomment 
the 2 lines of C hello world, prolog compiles without problem and my 
external predicate works as expected.  Both programs compile and run 
normally outside of prolog.

I'm not sure what to make of this.  Help would be greatly appreciated.  
Do I need to make some changes to my makefile perhaps?

Cheers,

Yvon


Prolog File
------------------------
     :- load("cvode_interface.so").
     :- external(t/1, p_interfacetest).
------------------------


C++ file
--------------------------------------------
#include "eclipseclass.h"    /*Prolog Eclipse interfacing with C++ stuff*/


#include <iostream>
using namespace std;
main(){cout << "Hello World in C++" << endl;}

//#include <stdio.h>
//main(){ printf("Hello World in C\n");}

extern "C" int p_interfacetest() {
     int test = 44;
     return unify(EC_arg(1), EC_word(test));
}
--------------------------------------------
Received on Fri May 18 2012 - 02:49:51 CEST

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