<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA -
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="ulink">
    <refnamediv>
        <refname>ulink</refname>
        <refpurpose>unlink/unload a dynamically linked shared object</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>ulink(x)
            ulink()
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <refsection>
            <title>Arguments</title>
            <variablelist>
                <varlistentry>
                    <term>x</term>
                    <listitem>
                        <para>
                            a ID returned by <literal>link</literal>
                        </para>
                    </listitem>
                </varlistentry>
            </variablelist>
        </refsection>
        <title>Description</title>
        <para>
            see <literal>link</literal>
        </para>
        <para>
            If you plan to use <literal>valgrind</literal> to profile
            your module, you must first set the environment
            variable <literal>PROFILE_SCILAB_DYNAMIC_LINK</literal> before
            starting scilab:
        </para>
        <programlisting role="example"><![CDATA[
# under bash shell:
export PROFILE_SCILAB_DYNAMIC_LINK=1
export SCILAB_VALGRIND_OPT="--db-attach=no --show-below-main=yes  --log-fd=2 --log-file=scilab.txt --num-callers=50 -v --trace-redir=yes --read-var-info=yes --trace-children=yes --show-reachable=yes --smc-check=all --child-silent-after-fork=no --leak-check=full --track-origins=yes"
scilab -nwni -profile
 ]]></programlisting>
        <para>This environment variable force Scilab not to release the
            loaded dynamic libraries. This will
            allow <literal>valgrind</literal> to perform its sum-up analysis.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
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');

ilib_for_link('fooc','fooc.c',[],"c");
exec loader.sce;

link() // Will should fooc
link("show") // Will should the value 0

ulink(0) // ulink fooc
 ]]></programlisting>
    </refsection>

    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="link">link</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
