dynamic linker
x = link(files [, sub-names,flag]);
link(x , sub-names [, flag]);
lstID = link("show")
lst = link()
: :listID returns the current linked ID routines. : :list returns names of functions linked. :
link is a incremental/dynamic link facility: this command allows to add new compiled Fortran or C routines to Scilab executable code. Linked routines can be called interactively by the function call. Linked routines can also be used as “external” for e.g. non linear problem solvers ( ode, optim, intg, dassl...).
link() returns a string matrix with linked functions.
a call to link returns an integer which gives the id of the shared library which is loaded into Scilab. This number can then be used as the first argument of the link function in order to link additional function from the linked shared library. The shared library is removed with the ulink command.
A routine can be unlinked with ulink. If the linked function has been modified between two links, it is required to ulink the previous instance before the new link.
link(‘show’) returns the current linked routines.
To be able to link routines in a system independent way, it is convenient to use the ilib_for_link utility function instead of link.
(Experienced) users may also link a new Scilab interface routine to add a set of new functions. See ilib_build and addinter functions.
Number of ‘link’ in a scilab session can be limited by the operating system. On Windows, you cannot load more than 80 dynamic libraries at the same time.
//Example of the use of ilib_for_link with a simple C code
`cd`_ TMPDIR
f1=['#include <math.h>'
'void fooc(double c[],double a[],double *b,int *m,int *n)'
'{'
' int i;'
' for ( i =0 ; i < (*m)*(*n) ; i++) '
' c[i] = sin(a[i]) + *b; '
'}'];
`mputl`_(f1,'fooc.c');
//creating the shared library: a Makefile and a loader are
//generated, the code is compiled and a shared library built.
`ilib_for_link`_('fooc','fooc.c',[],"c")
// display the loader.sce file which calls link
`mprintf`_('%s\n',`mgetl`_('loader.sce'))
// load the shared library
`exec`_ loader.sce;
link('show')
// call the new linked entry point
a=`linspace`_(0,%pi,10);b=5;
y1=`call`_('fooc',a,2,'d',b,3,'d',`size`_(a,1),4,'i',`size`_(a,2),5,'i','out',`size`_(a),1,'d')
// check
y1-(`sin`_(a)+b)
`exec`_ cleaner.sce;