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

From: Kish Shen <kisshen_at_...5...>
Date: Fri, 18 May 2012 18:05:57 +0100
Hi Yvon,

_ZSt4cout is defined in g++'s standard C++ library (libstdc++), so it 
looks like you are not loading this library when you load 
cvode_interface.so. Did you link in libstdc++ when you compiled 
cvode_interface.so, and do you have LD_LIBRARY_PATH set correctly (i.e. 
libstdc++ is in one of the specified directories in LD_LIBRARY_PATH).
[I am assuming you are using Linux or Solaris, since your file has a .so 
extension]

I know you are showing a simplified version of your program, but in 
general, it does not make sense to have a main() procedure in code that 
is intended for a dynamic library (.so) [I think your error is also 
caused by  the use of the << output function]. In addition, sending 
output in your C++ code to stdout (as done in <<) is probably not a good 
idea, as this depends on where stdout is directed to in the ECLiPSe 
session you are loading your file into.

Cheers,

Kish

On 18/05/2012 03:23, Yvon Muc wrote:
> 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));
> }
> --------------------------------------------
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users


-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Fri May 18 2012 - 17:06:05 CEST

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:20 CET