Linking a .mexglx, say foo.mexglx, file with Scilab.
(Assuming foo.mexglx has been created by the Matlab's mex script).

0/ Here I create the file foo.mexglx using Scilab, just to have a 
   proper foo.mexglx for testing (note that I copy libfoo.so to foo.mexglx 
   but internally the name libfoo.so is contained in foo.mexglx and 
   the dynamic loader will search libfoo.so (see below)).

-->ilib_for_link("foo",['foo.o'],[],"c");
-->host('cp libfoo.so foo.mexglx');

   If I have matlab 

-->host('mex -V4 foo.c');

1/ If necessary, create empty libmx.so libmex.so and libmat.so which 
   could be required by the .mexglx file.
   (If "ldd foo.mexglx" shows a dependency). 

This is done by the following commands:

-->ilib_for_link("mx",[],[],"c");
-->ilib_for_link("mex",[],[],"c");
-->ilib_for_link("mat",[],[],"c");

2/link the (almost empty) .so files with Scilab

// Note that this is not really  usefull 
//-->link ./libmx.so;
//-->link ./libmex.so;
//-->link ./libmat.so;

3/link foo.mexglx with Scilab
-->link ./foo.mexglx;

4/ Make a dynamic library with the provided C routine (libtst.c file).
   Note that you can use libtst.c file as is and that the entrypoint 
   MUST BE mexFunction. If you have more than one mexglx files you 
   will need to copy libtst.c and change only the function name 
   (this is described below) 

-->ilib_for_link("tst",['libtst.o'],[],"c");

5/At Scilab prompt enter:

-->addinter('./libtst.so','libtst','foo');
OR addinter ./libtst.so libtst foo to link libtst.so with Scilab.
Note that foo is the name of the Scilab function.

6/call the mexfunction:
-->foo(5,'foo')

Note that the mexfunction is called through the libtst function
using the entrypoint 'libtst' (not mexFunction!).
If several mexFunction are used, one should build several 
libtst.c file, one for each mexfunction, using a different name
e.g. libtst1.c libtst2.c ... Each mexFunction must be called through a
different entrypoint. 

Here Makelib and libtst.c are generic files while
Makextimesy and libxtimesy.c are adapted to xtimesy.mexglx.

*********************************************

OR ...
ld -shared -o foo.so libtst.so foo.mexglx -rpath `pwd`
addinter('./foo.so','libtst','foo');

EXAMPLE:
mexname='xtimesy';
mputl(strsubst(mgetl('libtst.c'),'libtst',mexname),'lib'+mexname+'.c');
mputl(strsubst(mgetl('Makelib'),'libtst','lib'+mexname),'Make'+mexname);
//make -f Makextimesy
// ld -shared -o xtimesy.so libxtimesy.o xtimesy.mexglx -rpath `pwd`
//OR :
link ./libmx.so;
link ./libmex.so;
link ./libmat.so;
link ./xtimesy.mexglx;
addinter('./libxtimesy.so','xtimesy','xtimesy')
xtimesy(2,3)




