1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
link(1) Scilab Function link(1)
NAME
link - dynamic link
CALLING SEQUENCE
link(files, sub-name)
link(files, sub-name, flag)
lst=link('show')
// Link extensions for machines using ``dlopen''
// (sun-solaris/linux-elf/alpha/hppa)
x=link(files [, sub-names,flag]);
link(x , sub-names [, flag]);
ulink(x)
PARAMETERS
files
: a character string or a vector of character strings. ld files used
to define the new entry point (compiled routines, user libraries, sys-
tem libraries,..)
sub-name
: a character string. Name of the entry point in files to be linked.
sub-names
: a character string or a vector of character strings . Name of the
entry points in files to be linked.
x : an integer which gives the id of a shared library linked into Scilab
with a previous call to link.
flag : character string 'f' or 'c' for Fortran (default) or C code.
names
: a vector of character string. Names of dynamically linked entry
points.
DESCRIPTION
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" com-
mand.
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.
REMARKS
IBM: For IBM-RS6000 only one program can be dynamically linked.
Demo:
When running a demo, you may have some trouble with the link due to
slight differences between systems. In this case, you modify the demo
by adding the needed libraries in the link command.
dlopen:
For machines using dlopen functionality extended command can be used.
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.
for example to link functions f and g form binary file test.o the two
following command can be used :
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.
show:
The command lst=link('show') will report information about linked
shared libraries and linked functions. The return value of the func-
tion lst is 1 or 0. If the return value is 1 then the extended calling
sequence described as Link extensions for machines using ``dlopen''
are accepted.
unlink :
(dlopen version) If the function f is changed and one wants to link
the new version, it is necessary to use unlink to get rid of previous
loaded versions of the function f
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');
scilab symbols:
In order to load a symbol from the Scilab code on can use
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'])
SEE ALSO
fort, c_link, addinter
|