1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
4
<LANGUAGE>eng</LANGUAGE>
6
<TYPE>Scilab Function</TYPE>
7
<DATE>April 1993</DATE>
8
<SHORT_DESCRIPTION name="link"> dynamic link</SHORT_DESCRIPTION>
10
<CALLING_SEQUENCE_ITEM>link(files, sub-name) </CALLING_SEQUENCE_ITEM>
11
<CALLING_SEQUENCE_ITEM>link(files, sub-name, flag) </CALLING_SEQUENCE_ITEM>
12
<CALLING_SEQUENCE_ITEM>lst=link('show') </CALLING_SEQUENCE_ITEM>
13
<CALLING_SEQUENCE_ITEM>// Link extensions for machines using ``dlopen'' </CALLING_SEQUENCE_ITEM>
14
<CALLING_SEQUENCE_ITEM>// (sun-solaris/linux-elf/alpha/hppa) </CALLING_SEQUENCE_ITEM>
15
<CALLING_SEQUENCE_ITEM>x=link(files [, sub-names,flag]); </CALLING_SEQUENCE_ITEM>
16
<CALLING_SEQUENCE_ITEM>link(x , sub-names [, flag]); </CALLING_SEQUENCE_ITEM>
17
<CALLING_SEQUENCE_ITEM>ulink(x) </CALLING_SEQUENCE_ITEM>
22
<PARAM_NAME>files</PARAM_NAME>
24
<SP>: a character string or a vector of character strings. <VERB>ld</VERB> files used to define the new entry point (compiled routines, user libraries, system libraries,..)</SP>
28
<PARAM_NAME>sub-name</PARAM_NAME>
30
<SP>: a character string. Name of the entry point in <VERB>files</VERB> to be linked.</SP>
34
<PARAM_NAME>sub-names</PARAM_NAME>
36
<SP>: a character string or a vector of character strings . Name of the entry points in <VERB>files</VERB> to be linked.</SP>
40
<PARAM_NAME>x</PARAM_NAME>
42
<SP>: an integer which gives the id of a shared library linked into Scilab with a previous call to <VERB>link</VERB>.</SP>
46
<PARAM_NAME>flag</PARAM_NAME>
48
<SP>: character string <VERB>'f'</VERB> or <VERB>'c'</VERB> for Fortran (default) or C code.</SP>
52
<PARAM_NAME>names</PARAM_NAME>
54
<SP>: a vector of character string. Names of dynamically linked entry points.</SP>
60
<P><VERB>link</VERB> is a dynamic link facility: this command allows to add new compiled
61
Fortran or C routines to Scilab executable code.
62
Linked routines can be called interactively by the function <VERB>fort</VERB>.
63
Linked routines can also be used as "external" for e.g.
64
non linear problem solvers (<VERB>ode</VERB>, <VERB>optim</VERB>, <VERB>intg</VERB>,
65
<VERB>dassl</VERB>...). Here are some examples:
68
The command <VERB>link('foo.o','foo','f')</VERB> links the Fortran
69
object file <VERB>foo.o</VERB> with the entry point <VERB>foo</VERB>.
72
The command <VERB>link('foo.o','foo','c')</VERB> links the C
73
object file <VERB>foo.o</VERB> with the entry point <VERB>foo</VERB>.
76
The command <VERB>link('SCIDIR/libs/calelm.a','dcopy')</VERB> links the
77
Fortran routine <VERB>dcopy</VERB> in the library <VERB>calelm.a</VERB>.
80
A routine can be linked several times and can be unlinked with
81
<VERB>ulink</VERB>. Note that, on some architectures (the ones on which
82
<VERB>ulink</VERB> exists) when a routine is linked several times, all
83
the version are kept inside Scilab.
86
Used with no arguments, <VERB>link()</VERB> returns the current linked routines.
89
If Scilab is compiled with static link (this is the default for
90
SystemV machines) you may have to include the system libraries in the
91
"link" command.
94
For example, if <VERB>foo.o</VERB> defines the object code of a routine named
95
<VERB>foo</VERB>, you will use <VERB>link</VERB> in one the following way:
100
link('foo.o -lm -lc','foo','c').
101
link('foo.o -lfor -lm -lc','foo').
102
link('foo.o -lftn -lm -lc','foo').
103
link('foo.o -L/opt/SUNWspro/SC3.0/lib/lib77 -lm -lc','foo')
107
If Scilab compiled with the "shared" option, the first example can be used
108
even if a warning for unresolved references is issued.
111
(Experienced) users may also <VERB>link</VERB> a new Scilab interface routine
112
to add a set of new functions.
113
See <VERB>Intersci</VERB> documentation for interface generation and
114
<VERB>addinter</VERB> function.
117
<SECTION label="Remarks">
120
<SP>For IBM-RS6000 only one program can be dynamically linked.</SP>
123
<SP>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.</SP>
125
<ITEM label="dlopen:">
126
<SP>For machines using dlopen functionality extended command can be used. a call to <VERB>link</VERB> 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 <VERB>ulink</VERB> command. for example to link functions <VERB>f</VERB> and <VERB>g</VERB> form binary file <VERB>test.o</VERB> the two following command can be used :</SP>
129
link('test.o',['f','g'])
137
x=link('test.o','f');
151
will also work but <VERB>f</VERB> and <VERB>g</VERB> will be loaded from two different shared libraries and won't be able to share data.
155
<SP>The command <VERB>lst=link('show')</VERB> will report information about linked shared libraries and linked functions. The return value of the function <VERB>lst</VERB> is <VERB>1</VERB> or <VERB>0</VERB>. If the return value is <VERB>1</VERB> then the extended calling sequence described as <VERB>Link extensions for machines using ``dlopen'' </VERB> are accepted.</SP>
157
<ITEM label="unlink :">
158
<SP>(dlopen version) If the function <VERB>f</VERB> 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 <VERB>f</VERB></SP>
161
x=link('test.o','f');
162
// if I need to reload a new definition of f a call to unlink
169
<ITEM label="scilab symbols:">
170
<SP>In order to load a symbol from the Scilab code on can use</SP>
173
link("Scilab",['Scilab-entry-point'])
177
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 )</P>
180
link("test.o",['Scilab-entry-point'])
184
Note that with <VERB>dld</VERB> (Linux machine aout) you can use an empty string</P>
187
link(" ",['Scilab-entry-point'])
201
<LINK>addinter</LINK>