Re: C++ & ECLiPSe

From: Oliver Obst <frvit_at_uni-koblenz.de>
Date: Wed 04 Nov 1998 03:11:47 PM GMT
Message-ID: <13888.25962.569349.390038@becher>
> I would like to invoke C++ written routines from ECLiPSe.. is it
> possible?

The easy way to do this is: (assuming you are using ECLiPSe on a
Solaris or a Linux machine, I don't know for Windoze)

1. write a C interface for your C++ routines (external "C" functions) 
2. make a dynamic (*.so) library and a C include file (*.h) of it
3. write a ECLiPSe interface in C using your new library

If you want to know how to compile and link an external ECLiPSe
library, I'd suggest printing out a copy of the chapter "Compiling and
loading" from the ECLiPSe Embedding and Interfacing Manual and NOT
read it. Burn it, because it's almost useless.

For linking external c library functions on linux you need either a
glibc linux system or ECLiPSe <= 3.5.2 .

Compiling the ECLiPSe library is easy:
gcc -c -I${ECLIPSEDIR}/include/${ARCH} library.c -o library.o
gcc -l <YOUR_C_LIBRARY> -fPIC -shared library.o -o library.so

On Solaris, use -G instead of -shared


> and how can I do it in a direct way?

You *can* link C++ libraries to ECLiPSe, but I'd suggest not to to so, 
because the interface is changing too often. Including the
following lines into your library might work (I tried this, but it's
too long ago to remember exactly.) You'll have to fiddle around with
compiler options.

#ifdef __cplusplus
# if ECLIPSE >= 40
#  define EC_EXTERNAL
#  define EC_EMBED
#  define Winapi
#  include "eclipseconfig.h"
#  include "ec_public.h"
#  include "types.h"
#  include "embed.h"
# elif ECLIPSE >= 36
#  include "eclipseconfig.h"
#  include "sepia.h"
#  include "eclipseclass.h"
#  include "error.h"
#endif


HTH
	Oliver

-- 
Oliver Obst    	           	http://www.uni-koblenz.de/~frvit/
AI Research Group -----------------------------------------------
Uni Koblenz       The problem with graduate students, in general,
0261 287-2768          is that they have to sleep every few days.
Received on Tue Nov 24 20:36:09 1998

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:03 PM GMT GMT