From mfamir@hss.hns.com Tue Jan  8 10:18:25 2002
Received: from hindon.hss.co.in ([202.54.26.202])
	by swi.psy.uva.nl (8.11.6/8.11.2) with ESMTP id g089IMT17999;
	Tue, 8 Jan 2002 10:18:23 +0100 (MET)
Received: from sandesh.hss.hns.com (sandesh [139.85.242.35])
	by hindon.hss.co.in (8.10.0/8.10.0) with SMTP id g089JNE22228;
	Tue, 8 Jan 2002 14:49:24 +0530 (IST)
Received: by sandesh.hss.hns.com(Lotus SMTP MTA v4.6.3  (733.2 10-16-1998))  id 65256B3B.00331581 ; Tue, 8 Jan 2002 14:47:58 +0530
X-Lotus-FromDomain: HSS
From: mfamir@hss.hns.com
To: prolog@swi.psy.uva.nl, xpce-users@swi.psy.uva.nl
Message-ID: <65256B3B.00330C98.00@sandesh.hss.hns.com>
Date: Tue, 8 Jan 2002 14:48:33 +0530
Mime-Version: 1.0
Content-type: text/plain; charset=us-ascii
Content-Disposition: inline
Subject: [SWIPL] Query: Building foreign libraries in prolog.



Hi All,

My platform is swi version 4.0.11 on Solaris 2.7.
We have built a prolog that contains some of the foreign code libraries included
in it.
Have adopted the following procedure for the same.

--------------------------- < Snip main.C  foreign code >
-------------------------
/* Include header files */
/* SWI-Prolog.h also included */

/* foreign function declarations */
/* for example */
extern "C"  foreign_t c_ts_connect(term_t, term_t);
...
...
PL_extension predicates[] =
{
  {"ts_connect",2,c_ts_connect,0},
...
...
  {NULL,0,NULL,0}
};

int main(int argc, char** argv)
{
  predicate_t pred;
  qid_t query;
...
...
  PL_register_extensions(predicates);
  if (!PL_initialise(argc,argv)) {
    fprintf(stderr, "couldn't initialize SWI\n");
    PL_halt(1);
  }
...
...
  pred = PL_predicate("check",0,"user");
  PL_call_predicate(NULL,0,pred,NULL);
  PL_toplevel();
...
...
  PL_halt(1);
}
--------------------------- < End Main file for C /c foreign code > -------------------------

Following are the compilation steps:
=============================
/usr/local/bin/g++ -c    -I/user/user2/SWI_XPCE/SWI-4.0.11/lib/pl-4.0.11/include
    -o main.o    main.C

/usr/local/bin/g++    -o  mypl    main.o   xml.o   dprintf.o   Portray_cl_lib.o
   glue.o \
   -L/user/user1/SWI_XPCE/SWI-4.0.11/lib/pl-4.0.11/runtime/sparc-solaris2.7 \
   -L/user/user2/tss1.8.10G/lib \
   -lpl -ltss -lnsl -lsocket -lpthread -lrt -ldl -lreadline -lcurses -lm
-------------------------------------------------------------------------------------------------------------

So, if I run "mypl" it gives me the prolog prompt with which I can execute the
API's
in the foreign code libraries.

My question is:
=============
I also need the functionality of xpce along with the other functionalities of my
 libraries
and the swi.
Is there any way I can make the xpce also available in the same executable,
"mypl".
The requirement also says that xpce should be statically linked so that I can
run the
same exe on the platform where swi / xpce is not installed.

I have an xpce version built with the static linking option i.e. swi + xpce. Can
 this built
be of some use in achieving the same.

Thanks in advance
Amir


Hughes Software Systems



