link - dynamic link
link is a 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 fort. Linked routines can also be used as "external" for e.g. non linear problem solvers (ode, optim, intg, dassl...). Here are some examples:
The command link('foo.o','foo','f') links the Fortran object file foo.o with the entry point foo.
The command link('foo.o','foo','c') links the C object file foo.o with the entry point foo.
The command link('SCIDIR/libs/calelm.a','dcopy') links the Fortran routine dcopy in the library calelm.a.
A routine can be linked several times and can be unlinked with ulink. Note that, on some architectures (the ones on which ulink exists) when a routine is linked several times, all the version are kept inside Scilab.
Used with no arguments, link() returns the current linked routines.
If Scilab is compiled with static link (this is the default for SystemV machines) you may have to include the system libraries in the "link" command.
For example, if foo.o defines the object code of a routine named foo, you will use link in one the following way:
link('foo.o','foo'). link('foo.o -lm -lc','foo','c'). link('foo.o -lfor -lm -lc','foo'). link('foo.o -lftn -lm -lc','foo'). link('foo.o -L/opt/SUNWspro/SC3.0/lib/lib77 -lm -lc','foo')
If Scilab compiled with the "shared" option, the first example can be used even if a warning for unresolved references is issued.
(Experienced) users may also link a new Scilab interface routine to add a set of new functions. See Intersci documentation for interface generation and addinter function.
link('test.o',['f','g'])
or
x=link('test.o','f'); link(x,'g');
But
link('test.o','f'); link('test.o','g');
will also work but f and g will be loaded from two different shared libraries and won't be able to share data.
x=link('test.o','f'); // if I need to reload a new definition of f a call to unlink // is necessary. ulink(x); link('test.o','f');
link("Scilab",['Scilab-entry-point'])
This does not work on all architectures. On some machines, on can link a Scilab internal function after a first call to link ( with a default binary file )
link("test.o",['Scilab-entry-point'])
Note that with dld (Linux machine aout) you can use an empty string
link(" ",['Scilab-entry-point'])